Solved

EASY: Applet not able to find class inside .jar file

Posted on 2004-10-16
9
264 Views
Last Modified: 2013-11-23
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"></applet></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.ClassNotFoundException" 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.
0
Comment
Question by:Emanuele_Ciriachi
  • 5
  • 3
9 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12328678
<applet code="DrawExample.class" name= "DrawExample" width="300" height="250"  CODEBASE="applets/DrawExampleFolder" archive="draw.jar"></applet>
0
 
LVL 1

Expert Comment

by:sammmyg
ID: 12328680
is there a reason why the applet has to be jarred up?
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 32 total points
ID: 12328682
try codebase as suggested above
http://www.cs.tut.fi/~jkorpela/HTML3.2/5.4.html
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12328690
Or try this

CODEBASE="."
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:Emanuele_Ciriachi
ID: 12328693
the reason is that there is more than one .class file in the applet. And because I -want- to get it working like that!
0
 
LVL 1

Author Comment

by:Emanuele_Ciriachi
ID: 12328701
The codebase paramenter is the -absolute- URL of the directory with the code?
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12328705
did u try codebase??
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12328715
You can give like this also
ODEBASE="http://site/applets/other/DrawExample/classes" as an example
0
 
LVL 1

Author Comment

by:Emanuele_Ciriachi
ID: 12328719
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...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Filesystem manipulation of Word Docx file (find replace text) 3 66
bitbucket vs gitbucket 3 57
Java array passed to SQL where clause 23 62
recursion example 16 111
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now