It's not a secret anymore!*
The moose likes Applets and the fly likes Applet can't find jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet can Watch "Applet can New topic
Author

Applet can't find jar file

Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
Hello,

I have made an applet and tested it and it works.
In this applet I have used library's such as the Apache Commons for example.
Now when i want to embed the applet in a webpage, the applet doesn't start.
The error is ;

java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpMethod
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 10 more
java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpMethod
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 10 more

It seems that the embedded Applet is unable to find the library wich I added to the classpath of the applet.
I have already tried to add the library to the classpath of my webproject ... does'nt work :s

Does anyone have any ideas?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Welcome to JavaRanch.

It seems that the embedded Applet is unable to find the library wich I added to the classpath of the applet.

How did you add it to the classpath? The only way to add additional jar files to an applet's classpath is to use an archive attribute as part of the applet tag.

I have already tried to add the library to the classpath of my webproject ... does'nt work

Whatever you do in the IDE has no impact on what happens after a proper deployment.


Ping & DNS - updated with new look and Ping home screen widget
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
You need to forget how the applet was developed and how the HTML was generated when you are trying to work out problems happening in a client's browser. As far as the browser is concerned all the files could be static on the server.
Consider what it takes for the browser to get all the components for the applet to work. That usually means having a correctly written <APPLET tag in an HTML file. Figure out what must be in the HTML for the browser to work, then back track to the server to make sure the correct HTML is generated and that the referenced files are in the correct locations on the server.
Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
aha now I understand.
I tried to add the archive in the Applet tag before but I didn't realize it was looking for the jar file in the same directory as the applet jar file.
Now i placed them all in the same directory and the applet loads.

thanks guys.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet can't find jar file
 
Similar Threads
Applet notinit...
Applet not initiated
jacl Incompatible magic value
Getting error while displaying tif image in applet through browser.
JAI with applet problem