Solved

Applet wont load in browser

Posted on 1998-07-14
13
221 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
noX challenge 17 76
json format text only 4 65
Running Jira on Raspberry PI 2? 3 130
Java array passed to SQL where clause 23 43
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

759 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

21 Experts available now in Live!

Get 1:1 Help Now