Friday, June 06, 2008

java 6 + applet + firefox 2 = hang

fyuuuh...

finally I can get my applet working in firefox,

I'm writing an applet application in my ubuntu box, and here's the first configuration
  • eclipse 3.3
  • jdk1.6.0_03
  • firefox 2.0.0.14
  • sun java plugin 6
I can write, compile and run the applet using applet-viewer built in eclipse, but some how everytime I try to deploy the applet to a web page, and view it with firefox, it crash! even until now I dont know why it crashed, been searching on forum and googling, I didnt find anything sufficient to solve my problem(or just me being dumb).. I was thinking maybe theres something wrong with java6 especially with applets, because not only my applet wont work, applet from another site doesn't work either(I've tried with realapplets).

so, I tried my luck with java5, and here's the second configuration
  • eclipse 3.3
  • java-1.5.0-sun-1.5.0.13
  • firefox 2.00.14
  • sun java plugin 5
I've flush everything related with java6 in my laptop away, and replace it with java5, and ofcourse change the default java build path on my eclipse. I can write it compile it, but can't run it!!, it says

java.lang.UnsupportedClassVersionError: Bad version number in .class

oops, forgot to change the JDK compliance setting on my eclipse from 6.0 to 5.0 (window->preferences->java->compiler), voila, it run :)

if any of you wondering whats the error above, basically because you've build a java program using newer compiler, but running it under older jre. For example you've compiled your program using JDK 1.6, on eclipse, and when you tried to run it with your default jre set to 1.5, then you'll get those error throw at you.

And yes, with java5 I was also able to run applet from another site..
so for now my conclusion is,
don't use java6, if you want to write, or run applet application
I hope they'll fixed it soon..

and just a tip:
when you deploy your applet on web page, if you've put your .class file(s) under a directory inside your web root, don't prefix the code properties of applet tag with "./", or browser will say applet loading failed.
dont use :
<applet code="./control/HelloWorld.class" height="400" width="400"></applet>
instead use :
<applet code="control/HelloWorld.class" height="400" width="400"></applet>

keyword : applet, firefox, java 6 plugin, ubuntu, hang, crashed

5 comments:

My Space said...

just want to leave a comment.
nice blog-u write it in english i mean...
first step to go international huh?
hehhehe..
gud luck.
thx for the link anyway. :)

Zeft said...

your always welcome :)

virs said...

fufufu.....
nice blog...

actually i dont know what to say just feel that i want your brain :D :D

Zeft said...

like I've said before, my brain is a bundle with everything else :)

Anonymous said...

I upgraded to Java6 and the desktop applets would hang. I went back to Java5 and things seems to work again sort of... Still in transition thinking it may be a firewall problem blocking applets, but this just started happening as of last week 8/11/2008. It hangs with firefox and IE~