so twitter4j and a java applet go on safari…

By | December 1, 2010

Alrighty, I’m going to go ahead and interrupt my workflow on the ever so slight, but still non-zero, chance that someone else in the world is struggling with incorporating twitter4j into a deployable Java applet. I’ve been slamming my head against the wall (figuratively… so far), and since I couldn’t (easily) find this information, I hope this will help… someone… eventually.

First, a little background: for my Java Music Systems course this semester, I’ve settled on a project with the goal of developing an applet that can interactively sonify Twitter data in real-time. How, exactly, is an aesthetic decision I have yet to make, but I’m probably going to need access to the streaming API. Regardless of how this ultimately makes sound, one thing is unavoidable: I need OAuth handshaking.

If you know anything about OAuth, your eyes are probably already wide with security concerns related to trying to pull this off in any kind of client-side software. I know. I’ll be the first to admit that an applet is probably not the best platform for the task at hand, so I’ll dodge that responsibility with a “that’s not the point, I’m supposed to use an applet.” However, the bottom line is this: it would appear that, at least for the twitter4j API, an unsigned applet cannot make the requests necessary for OAuth authentication. Womp.

make a couple twitter4j calls and your unsigned app gets the cold shoulder...

In hindsight, this makes sense. I’m new to Java and the bittersweet sentiment I’ve fostered toward applet development, but locking out the applet’s access to other servers definitely feels like something I read somewhere. Figuring out for certain that this was in fact the issue, though, took far too long.

I was rather surprised to learn that neither Google Chrome or Mozilla Firefox have active/up-to-date Java Console plugins for developers. My initial reaction was, “geez, everyone must really be calling it quits on Java Applets” (although with JavaFX being effectively shipped with NetBeans, I may just be developing with the wrong tools). Safari, on the other hand, offers a native Java console for all of your live debugging purposes. This can be toggled through /Applications/Utilities/Java, where you’ll want to go ahead and set “Show Console” under the Advanced tab. Disclaimer, this is all with respect to OS X 10.6, so your mileage will vary on a different OS.

In summary:

  • The Twitter API is sweet, and I definitely recommend checking it out. I’m having far more fun with Twitter as a developer than as a user.
  • Twitter4J is also sweet. Major kudos to YY and his hard work…
  • But it looks like it won’t work in an unsigned applet.
  • Safari has a Java console (ftw). Chrome and Firefox, no dice.

And with that, it’s back to the grind.

Leave Your Comment

Your email will not be published or shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>