This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run Applet in Firefox -> NoClassDefFoundError ?

 
AhFai Chan
Ranch Hand
Posts: 81
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have created some applets in Eclipse and tried to run them from Firefox 42.0
Eclipse is on J2SDK1.7.0 and JRE is on 1.8.0, I have also set the Java Security to allow access to file:///C:/users/
When the applet is run from Eclipse, I got the right result.
But when I run the html from Firefox I got a "NoClassDefFoundError"

At the moment I don't know where the error is. Did some googling and seems like a lot of people have this problem since JRE1.8.0

Applet and html in same directory!

error message:
-------------
security = 0
lapURL = file:/C:/Users/ARTHUR/eclipse/workspace/JavaTests/bin/java101//HelloWorld/
appArgs = ##docbase:file:/C:/Users/ARTHUR/eclipse/workspace/JavaTests/bin/java101/HelloWorld.html##Parameters:Y29kZQ===SGVsbG9Xb3JsZC5jbGFzcw==,Y29kZWJhc2U==ZmlsZTovLy9DOi9Vc2Vycy9BUlRIVVIvZWNsaXBzZS93b3Jrc3BhY2UvSmF2YVRlc3RzL2Jpbi9q
YXZhMTAxLw==,aGVpZ2h0=MTAw,amF2YV9hcmd1bWVudHM==,d2lkdGg==MzAw,
basic: error: HelloWorld (wrong name: java101/HelloWorld).
java.lang.NoClassDefFoundError: HelloWorld (wrong name: java101/HelloWorld)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
security: Reset deny session certificate store
basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@ac7b65
security: Reset deny session certificate store



Eclipse applet
--------------


html run from Firefox 42.0, in same directory as applet
-------------------------------------------------------
<html><applet code="HelloWorld.class" width="300" height="100">
</applet>
</html>


 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the applet class is in package java101 you need to specifiy the package as part of the class name. ie

You will probably also need to move the html to the java101 directory or put the class in a jar and add the 'archive' parameter to the html ie

 
AhFai Chan
Ranch Hand
Posts: 81
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:Because the applet class is in package java101 you need to specifiy the package as part of the class name. ie

You will probably also need to move the html to the java101 directory or put the class in a jar and add the 'archive' parameter to the html ie



Thanks Tony, including the package detail helped overcome the error.

Only problem is, when I execute the applet from Firefox, it lost the Frame, but when I execute it from Eclipse, the Frame is there.

 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default, when applets are displayed in a web page they don't have a frame. What you are seeing in Eclipse is the frame of the appletviewer which is a special frame used to display applets outside of a browser.
You can always get your applet to draw a border around itself if you want or even have your applet create and display a JFrame if you want it to look like a desktop app - Note: the frame like look like but not work like a desktop frame.
 
AhFai Chan
Ranch Hand
Posts: 81
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:By default, when applets are displayed in a web page they don't have a frame. What you are seeing in Eclipse is the frame of the appletviewer which is a special frame used to display applets outside of a browser.
You can always get your applet to draw a border around itself if you want or even have your applet create and display a JFrame if you want it to look like a desktop app - Note: the frame like look like but not work like a desktop frame.


Thanks Tony, all done and the sun shines for me again
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic