?
Solved

NoClassDefFoundError when loading applet

Posted on 2003-03-24
24
Medium Priority
?
276 Views
Last Modified: 2013-12-29
Hi,

I am loading the page from Apache.  Browser MS IE 6.  I am getting

The applet Html file and the class file is in the same directory called "main".  The class is in a package called "main".

In the parent directory I have a "com" directory with some extra classes.

This is the applet tag:
<APPLET codebase=.. code="main/SystemPage.class" width="100%" height="100%">

This is the Java Console output:
Error loading class: main.SystemPage
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: main.SystemPage
     at com/ms/vm/loader/URLClassLoader.loadClass
     at com/ms/vm/loader/URLClassLoader.loadClass
     at com/ms/applet/AppletPanel.securedClassLoad
     at com/ms/applet/AppletPanel.processSentEvent
     at com/ms/applet/AppletPanel.processSentEvent
     at com/ms/applet/AppletPanel.run
     at java/lang/Thread.run



I tried this and the same problem:
<APPLET codebase=. code="./SystemPage.class" width="100%" height="100%">

The has rwx privileges.

Thanks,

Alex.
0
Comment
Question by:akoifman
[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
  • 10
  • 9
  • 3
  • +1
24 Comments
 
LVL 3

Expert Comment

by:allahabad
ID: 8199659
<APPLET code="man.SystemPage" width="100%" height="100%">
0
 

Author Comment

by:akoifman
ID: 8199729
Same problem, if I do:
<APPLET code="main.SystemPage" width="100%" height="100%">
or
<APPLET code="main.SystemPage.class" width="100%" height="100%">

0
 
LVL 3

Expert Comment

by:allahabad
ID: 8199782
keep you html file one level up from main directory, and class file in main directory.
0
Technology Partners: 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!

 
LVL 3

Expert Comment

by:allahabad
ID: 8199794
<html>
<applet code="main.SystemPage" width=200 height=120>
</applet>
</html>

do'nt give "main.SystemPage.class".
0
 
LVL 92

Expert Comment

by:objects
ID: 8199885
try:

<APPLET codebase=.. code="main.SystemPage" width="100%" height="100%">

0
 
LVL 92

Expert Comment

by:objects
ID: 8200675
or try:

<APPLET codebase=".." code="main.SystemPage.class" width="100%" height="100%">
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8200854
Please check if the .class file is in the main sub-folder or in the folder one level up.

NoClassDefFound error generally happens only when it does not find the .class file itself.

Mayank.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8201573
0
 

Author Comment

by:akoifman
ID: 8204991
Still no go in MS IE 6.  If I enable Use Java (sun) in IE/Properties/Advanced, then this line works:
<APPLET codebase=".." code="main.SystemPage.class" width="100%" height="100%">

I have another page that generates NoClassDefFoundError.  Other pages with a similar Applet tag work.  All in the same directory.  These two non-working pages use an applet in the code= that embed other applets.  For example, SystemPage.java does a new of a sysPage applet.  Do I have to add sysPage.class in the code=?  Do I have to use a jar?

All work fine in the applet viewer.  Or when run in the NetBeans debugger.

The applets are AWT.  

Thanks,

Alex.
0
 
LVL 92

Expert Comment

by:objects
ID: 8206125
> These two non-working pages use an applet in the code that embed other applets.

Perhaps problem is with how u are embedding applet, can you post your code.
0
 

Author Comment

by:akoifman
ID: 8213761
Hi, thanks for your suggestions.  I think the problem is not in the Applet tag.  I suspect the reason is that my IDE uses a higher compiler than the browser can handle.  If I compile the classes with a different compiler then I do not have this exception.  I do have other problems.

I just loaded the old jdk1.1.8.  I want to use Javac to compile the sources.  This will produce the target for the browser.

Can you post a sample Javac -classpath with multiple directories, Zip, and Jar files?

I also suspect that the exception problem can be caused by some classes compiled at home and some at work (even though I have very similar version of JDK).  I do not know what else to suspect.

Please post the Javac command line.

Thanks,

Alex.
0
 
LVL 92

Expert Comment

by:objects
ID: 8214050
You can use any compiler, just use:

javac -target 1.1 x.java
0
 

Author Comment

by:akoifman
ID: 8214199
I see no -target option.

C:\javac -target 1.1 GraphApplet.java
javac: invalid flag: -target
use: javac [-g][-O][-debug][-depend][-nowarn][-verbose][-classpath path][-nowrit
e][-deprecation][-d dir][-J<runtime flag>] file.java...

c:\>java -version
java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)
0
 
LVL 92

Expert Comment

by:objects
ID: 8214230
What jdk version are you using?

If you are using 1.1, then -target is not available (as there is only one possible target).
0
 

Author Comment

by:akoifman
ID: 8215078
Java -version shows 1.3.1_02.  See above.

Is there such a thing as the browser Java cash.  I think MS IE keeps the old classes cashed.  I deleted files from Properties/General/Delete Files and even rebooted my PC.  But the old classes are still there.  I am NOT joking.

Thanks.
0
 
LVL 92

Expert Comment

by:objects
ID: 8215118
> Java -version shows 1.3.1_02.  See above.

Thats your JVM, not your compiler.

> Is there such a thing as the browser Java cache.

Yes, it depends on your jvm and html exactly where the caching is handled.
Did you try clearing the browsers cache?


0
 

Author Comment

by:akoifman
ID: 8215184
I cleared MS IE cash:
I deleted files by goinf to IE Properties/General/Delete Files and even rebooted my PC.  
0
 
LVL 92

Expert Comment

by:objects
ID: 8215205
what vm are you using?

what html are you using?
0
 

Author Comment

by:akoifman
ID: 8215233
Microsoft VM in MS IE 6 on XP.
Using simple html file, with just an applet tag.  No dynamic html or javascript.
0
 
LVL 92

Accepted Solution

by:
objects earned 1200 total points
ID: 8215315
Should be ok then, why do you think the old classes are still there?

Are you sure it is not picking up the class files locally from your classpath.
0
 

Author Comment

by:akoifman
ID: 8215376
I had a previuos class version with some println.  I removed that println and deleted all class files.  In my browser I see this println in the Java console.  If I load the same page on another PC the applet behaviour is different (as expected with the latest changes) and no printouts in the Java console.

Classpath should not be visible to a browser.  Even if I had one.  But I do not have this class file anywhere else on my PC except in the web server directory.
0
 

Author Comment

by:akoifman
ID: 8228014
The problem went away when I compiled the sources with -target 1.1.

Object gave me a lot of tips.

I appreciate his input.

Thanks,

Alex.
0
 

Author Comment

by:akoifman
ID: 8228019
Thanks for your valuable advise.  -target 1.1. option fixed it.
0
 
LVL 92

Expert Comment

by:objects
ID: 8229326
Happy I could help :-)
Thanks for the points.
0

Featured Post

Industry Leaders: 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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month9 days, 6 hours left to enroll

764 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