Emanuele_Ciriachi
asked on
EASY: Applet not able to find class inside .jar file
Hello everyone from your all-times favorite java noob.
My intention: I wrote a silly Hello World Java application to run inside an applet. It -works- if I put both the .class file and the .html file inside the same webserver directory.
The .html file is made like this:
---DrawExample.html---
-------------------------- ---
<html>
<body>
<p><applet code="DrawExample.class" name= "DrawExample" width="300" height="250" archive="draw.jar"></apple t></p>
You need a Java-enabled browser to view this.<br>
</body>
</html>
-------------------------- ---
Then I have a the .jar file containing the WORKING .class file inside this file which is inside the SAME directory as the .html file, you can check by yourself at this address:
http://www.biomatlab.net/Applet/Applet2/draw.jar
I get a "Java.lang.ClassNotFoundEx ception" error everytime I try to run the applet, telling me that "DrawExample.class cannot be found".
But the .class file is inside the .jar file. And the .jar file is inside the same directory of the webserver as the .html file referring it. And the .html file clearly states that the archive to look for is "draw.jar" I correctly prepared. So it should work.
What's wrong in this chain of reasoning? I will try out your suggestions to make the damn thing work, and award the points to the first one posting the correct solution.
My intention: I wrote a silly Hello World Java application to run inside an applet. It -works- if I put both the .class file and the .html file inside the same webserver directory.
The .html file is made like this:
---DrawExample.html---
--------------------------
<html>
<body>
<p><applet code="DrawExample.class" name= "DrawExample" width="300" height="250" archive="draw.jar"></apple
You need a Java-enabled browser to view this.<br>
</body>
</html>
--------------------------
Then I have a the .jar file containing the WORKING .class file inside this file which is inside the SAME directory as the .html file, you can check by yourself at this address:
http://www.biomatlab.net/Applet/Applet2/draw.jar
I get a "Java.lang.ClassNotFoundEx
But the .class file is inside the .jar file. And the .jar file is inside the same directory of the webserver as the .html file referring it. And the .html file clearly states that the archive to look for is "draw.jar" I correctly prepared. So it should work.
What's wrong in this chain of reasoning? I will try out your suggestions to make the damn thing work, and award the points to the first one posting the correct solution.
<applet code="DrawExample.class" name= "DrawExample" width="300" height="250" CODEBASE="applets/DrawExam pleFolder" archive="draw.jar"></apple t>
is there a reason why the applet has to be jarred up?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or try this
CODEBASE="."
CODEBASE="."
ASKER
the reason is that there is more than one .class file in the applet. And because I -want- to get it working like that!
ASKER
The codebase paramenter is the -absolute- URL of the directory with the code?
did u try codebase??
You can give like this also
ODEBASE="http://site/applets/other/DrawExample/classes" as an example
ODEBASE="http://site/applets/other/DrawExample/classes" as an example
ASKER
You are the man, sudhakar, works perfectly.
Anyway, this applet thing sucks. Couldn't they just try to look in the folder of the .html file? No no no, mama's boy want me to tell him EXACTLY the path! Oh well...
Anyway, this applet thing sucks. Couldn't they just try to look in the folder of the .html file? No no no, mama's boy want me to tell him EXACTLY the path! Oh well...