• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

NoClassDefFoundError

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone know how to remody this lovely error:

java.lang.NoClassDefFoundError: hang_cipher/Applet_Control (wrong name: Applet_Control)

This appears after I have passed through the security warning. Unverified signature.
The resource is a JApplet

Java defines this error as "Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. "

Does this mean that I have to supply all the java libraries I am using with the applet. This would seem a little excessive.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The "wrong name" part usually indicates that there's something wrong with the package or directory hierarchy. Is class Applet_Control in package hang_cipher? And is it inside a directory of that name and that directory is at the same level as the HTML file containing the applet tag? Or, if you're using a jar file- is that correctly packaged?

Does this mean that I have to supply all the java libraries I am using with the applet. This would seem a little excessive.


I'm not sure what you mean by that. All 3rd party libraries used by the applet need to be available at runtime, and be specified in the applet tag.
 
Simon Poet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help.

The structure is as follows:

I am using a server www.computingscotland.org although I don't have root access to the server.

Check it out its a lovely site to encourage kids to study Computer Science.

In the folder '/' which is the top level area I have access too i.e. the area where all the files are stored is a page .php file in which the JApplet is embeded.(address http://www.computingscotland.org/hangcipher.php)

It has been embeded as follows:

<!--[if !IE]>-->
<object classid="java:hang_cipher.Applet_Control.class"
type="application/x-java-applet"
archive="/Applet/hang_cipher.jar"
height="800" width="710" >
<!-- Konqueror browser needs the following param -->
<param name="archive" value="/Applet/hang_cipher.jar"/>
<!--<![endif]-->

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
height="800" width="710" >
<param name="code" value="hang_cipher.Applet_Control" />
<param name="archive" value="/Applet/hang_cipher.jar"/>
</object>
<!--[if !IE]>-->
</object>
<!--<![endif]-->

The jar file containing the code is here

http://www.computingscotland.org/Applet/hang_cipher.jar

Inside the jar file is a package called hang_cipher and inside this package is Applet_Control which extends JApplet

I have not used any 3rd party packages but have made use of swing, io ect. which java has provided.

Hope I can get this working.....
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that class Applet_Control is not actually in package hang_cipher; it is not in any package, and thus should not be in a directory inside of the jar file, and should not be referenced as if it were.
 
Simon Poet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have package statements at the top of each of my java files, in eclipse it is within a package and this looks like a folder when using windows explorer. So I'm a bit confused.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's odd, because the source files (which were included in the jar file) do not have a package statement.
 
Simon Poet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well Spotted, thanks for the help as well.

I thought I had uploaded a different version, I guess not
Ok I removed the hang_cipher. part but it returns the same error message
you can will be verify this from page source and the jar file

Quite a frustrating problem and Im not sure how to proceed.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just downloaded the jar file again - the source still doesn't have package statements.
 
Simon Poet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I know I thought I would try it without the package statements, I have removed the references to a package to reflect this.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Simon Poet:
Yes I know I thought I would try it without the package statements, I have removed the references to a package to reflect this.



But all the classes are still inside of the hang_cipher directory in the jar file; that's why it doesn't work.
 
Simon Poet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I tried this I successfully created a jar files where the classes were not in a directory but jarsigner puts them in a directory.
I am using the command

jarsigner hang_cipher.jar myalias
 
Simon Poet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I have got passed this error. The heirarchy of the jar file was wrong. I managed to get passed the error by holding all my files in a package which was in the jar file. One directory depth seems to be both the minimum and the maximum for a signed jar file.

But now I have a null pointer exception but that's programming for you

I would conclude that if you sign a jar then it must be in a package because it puts all the files into a directory.
 
Simon Poet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh one more point, I was using the eclipse IDE but whenever I build my .jar using java jar tool it would mess up the hierarchy perhaps its got something to do with how eclipse lays out its files. Better to use the Export function in eclipse to generate the .jar

[ September 07, 2007: Message edited by: Simon Poet ]
[ September 07, 2007: Message edited by: Simon Poet ]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,file name and class name of the program should be same.also check whether the class file you are passing to HTML code is f the respective public class.
if not solved,please patch small code thats why we could come to understand exact problem.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic