?
Solved

Applet wont load in browser

Posted on 1998-07-14
13
Medium Priority
?
263 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

765 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