Solved

Applet wont load in browser

Posted on 1998-07-14
13
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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
 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

726 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