Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

NoClassDefFoundError when loading applet

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
akoifman
Asked:
akoifman
  • 10
  • 9
  • 3
  • +1
1 Solution
 
allahabadCommented:
<APPLET code="man.SystemPage" width="100%" height="100%">
0
 
akoifmanAuthor Commented:
Same problem, if I do:
<APPLET code="main.SystemPage" width="100%" height="100%">
or
<APPLET code="main.SystemPage.class" width="100%" height="100%">

0
 
allahabadCommented:
keep you html file one level up from main directory, and class file in main directory.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
allahabadCommented:
<html>
<applet code="main.SystemPage" width=200 height=120>
</applet>
</html>

do'nt give "main.SystemPage.class".
0
 
objectsCommented:
try:

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

0
 
objectsCommented:
or try:

<APPLET codebase=".." code="main.SystemPage.class" width="100%" height="100%">
0
 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
0
 
akoifmanAuthor Commented:
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
 
objectsCommented:
> 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
 
akoifmanAuthor Commented:
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
 
objectsCommented:
You can use any compiler, just use:

javac -target 1.1 x.java
0
 
akoifmanAuthor Commented:
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
 
objectsCommented:
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
 
akoifmanAuthor Commented:
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
 
objectsCommented:
> 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
 
akoifmanAuthor Commented:
I cleared MS IE cash:
I deleted files by goinf to IE Properties/General/Delete Files and even rebooted my PC.  
0
 
objectsCommented:
what vm are you using?

what html are you using?
0
 
akoifmanAuthor Commented:
Microsoft VM in MS IE 6 on XP.
Using simple html file, with just an applet tag.  No dynamic html or javascript.
0
 
objectsCommented:
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
 
akoifmanAuthor Commented:
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
 
akoifmanAuthor Commented:
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
 
akoifmanAuthor Commented:
Thanks for your valuable advise.  -target 1.1. option fixed it.
0
 
objectsCommented:
Happy I could help :-)
Thanks for the points.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 10
  • 9
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now