YAEJP...

Yet Another Executable Jar Problem... :)
I completed the first part of the Dive Log tutorial here on Sun's website, and I decided to make an executable JAR file. I create the following manifest file and put it in the appropriate directory in the JAR:
Manifest-Version: 1.0
Created-By: Me
Main-Class: DiveLog
Note that there is a carriage return after the Main-Class statement. I run it by double-clicking and I get the usual "couldn't find main class" stuff. I open a console and run it with "java -jar divelog.jar" with the following results:
Exception in thread "main" java.lang.NoClassDefFoundError: DiveLog (wrong name:
divelog/DiveLog)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Then I read somewhere that if your main class is part of a package, you must use its full name or whatever, so I change the Main-Class attribute to "divelog.DiveLog", as all the .java files were part of package "divelog", and run the JAR again, now getting this:
Exception in thread "main" java.lang.NoClassDefFoundError: divelog/DiveLog
Can anyone explain to me what is wrong here?

Update: Since the
classes were all defined as part of a package, they
were expected by the interpreter to be under a
'divelog' directory within the archive. Which is why I suggested that you run it from the command line using the command I suggested.
At first I had assumed it was a
problem with the manifest, although I did have to
change the Main-Class attribute to point to
'package.Class' instead of just 'Class'.If it doesn't run the way I suggested then it is guaranteed to have nothing to do with the manifest.

Similar Messages

Maybe you are looking for

  • Windows 7, 64 bit OS can't print to networked 1300n printer

    I have a 1300n printer directly connected to a home network. Seveal computers successfully access and print to this cprinter using OS XP PRO and Windows7 32 bit. When I downloaded and installed the 64 bit drivers on the new computer and printed a tes

  • CCMS and PMI monitoring

    Hi,    I do have some doubts regarding CCMS and PMI monitoring..    As of now we are plannig to configure CCMS.But i want to know about PMI.. when it comes to the picture in monitoring.     How PMI is different from CCMS ? and which one is the better

  • Print-out different on Officejet 6500A and Officejet 8600Plus

    Dear Sir, I have file on Words program, that I never changes the page layout, but everytime I print that file, in either of those to printer they never be the same print-out result, meaning : If I print the same file on 6500A the result are not the s

  • Between a rock and a hard place :(

    This is a cross platform dilemma; After Effects / Flash / Premiere. Made a complex After Effects illusion (360 MB SWF file) that I need to make a video of. Put it into Premiere but the "Export to Media" did not do a very good job of it. Tried quickti

  • Save/use variant from a macro

    Currently, I'm setting prompt values for a macro---ie, not using the prompt selection screen. Is there a way that once my variables are set, I can save this to a variant via macro? Additionally, any way I can retrieve a saved variant via macro?