Solved

Applet wont load in browser

Posted on 1998-07-14
13
233 Views
Last Modified: 2010-03-30
JDK: 1.1.6
Platforms: NT 4.0, HP-UX, Solaris

I have been working on an applet for several days, it compiles fine and runs great in the appletviewer, but when i place it on a webserver i cant load it in a browser.  I have been trying to use Netscape 4.05 for Solaris and NT, and IE 3.02 for Win95, with no luck.

I get this error in the Java console.
# Applet exception: error: java.lang.NoClassDefFoundError: TankTest
java.lang.NoClassDefFoundError: TankTest

The classes were compiled on the webserver, and eveyrthing is in one directory, so it should work fine.

Do I perhaps need to set my codebase in the html file?

In case you want to see for yourself:
http://www.umr.edu/~mfischer/tank/tanktest.html
0
Comment
Question by:mfischer2
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 5

Expert Comment

by:fontaine
ID: 1226183
In the HTML you wrote:

<applet code="TankTest.class" codebase="/afs/umr.edu/users/mfischer/public_html/tank" width=500 height=500></applet>

I have the feeling that the codebase given is the local path, not the network path, what would
explain the problem. If the HTML file is in the same directory as the class files, you can
simply drop the codebase. I.e.:

<applet code="TankTest.class"  width=500 height=500></applet> is enough.

If the classes are not in the same directory, then you use the codebase attribute, that has
to contain a URL to the directory containing the classes. Here is a good explanation
about that:

http://java.sun.com/docs/books/tutorial/applet/appletsonly/html.html


0
 

Author Comment

by:mfischer2
ID: 1226184
I had no codebase earlier with the same results, i also tried
codebase = "."
0
 

Author Comment

by:mfischer2
ID: 1226185
I had no codebase earlier with the same results, i also tried
codebase = "."
0
 
LVL 5

Expert Comment

by:msmolyak
ID: 1226186
Could you describe the directory structure on the Web server where the applet comes from. Indicate where the HTML file is located and wher TankTest.class is. Also specify what URL you use in your browser to access the HTML file.
0
 

Expert Comment

by:drasin
ID: 1226187
You ought to try putting your applet code in the same directory as the HTML, and seeing if the applet will run then.  If it does, the issue must indeed be the codebase path.  Remember, the codebase must be accesible from the WWW, or the browser won't be able to run it.
0
 

Author Comment

by:mfischer2
ID: 1226188
The html file and the class files are in the same directory,
the html file is accessible according to the permissions and
that I see the file loading, but then fail.
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 5

Expert Comment

by:msmolyak
ID: 1226189
Below are the messages reported by the browser when I tried to run your applet:

# Fetching http://www.umr.edu/afs/umr.edu/users/mfischer/public_html/tank/TankTest.class
# Applet exception: class TankTest not found

Note the URL the browser is using to read your applet class.

What if you use "codebase=http://www.umr.edu/~mfischer/tank" in your applet.
0
 

Author Comment

by:mfischer2
ID: 1226190
Tried that just now:
<applet code="tanktest.class" codebase="http://www.umr.edu/~mfischer/tank" width=500 height=500>

Heres what I got:
# Applet exception: class tanktest not found
java.lang.ClassNotFoundException: tanktest

I didnt get that path message that you got, but I have been changing the HTML during the day (just a few changes), so you may have looked at it then.
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1226191
Class names are case sensitive. tanktest.class is not the same as TankTest.class in Java...
My explanation still remains valid: you don't need the codebase as the classes and the
HTML are in the same directory.
0
 
LVL 6

Accepted Solution

by:
gadio earned 150 total points
ID: 1226192
mfischer2, your problem is simple. You used the new event model (the java.awt.event.*). This package is not supported by the Netscape (I guess that you checked only on Netscpae right?). The IE4 does support the new model and you will find that your applet works there (nice little abrams image). What you should do is to move to the old UI event model, or restrict your users to IE4, or use the jdk1.1 patch for netscape (the best for the users is that you move to the old event model).
G.
0
 
LVL 5

Expert Comment

by:fontaine
ID: 1226193
mfisher2's problem was the use of a local path for the codebase, as I mentioned in my
previous answer, combined, I have the feeling, with the fact that he refered to the class as
TankTest.class instead of tanktest.class (in the question, he talked about TankTest.class and about tanktest.class in the last comments) . With a browser that only supports the old event model, if the class is actually found, the message would be a java.lang.VerifyError because there is an attempt to use a java something package that is not known by the VM.
0
 

Author Comment

by:mfischer2
ID: 1226194
Thanks alot, that fixed it. (using IE 4.0)  I guess its my fault for not reading more beforing un-deprecating my code.  (about tanktest and TankTest for the curious, TankTest was there to try and fix it, tanktest was the real version that was uploaded later, thats why the change).  A quick follow-up, should I undeprecate or wait for Netscape to catch up?
0
 
LVL 6

Expert Comment

by:gadio
ID: 1226195
I would recommend you to use the old event model (that would cause you to get 'deprecation' warnings during compilation), because its not so attractive to force your users to use IE4. And its not too dificult to work in the old model. I dont think that you can wait for netscape to catch up since their plans and time tables are quite vage.
G.
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

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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

863 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

18 Experts available now in Live!

Get 1:1 Help Now