I am trying to run a jar file using my command prompt (Windows XP) but get NoClassDefFoundError.
I have my DateAndTime.class file in a folder called dateandtime and also indicated a package called dateandtime in the source file.
Outside the folder I have a manifest.mf file with specification.
I put this in the command line.
jar cmf manifest.mf myJarFile.jar dateandtime
and this creates the myJarFile.jar in the same folder as manifest.mf.
When I try to run this jar file however I get the NoClassDefFoundError.
Exception in thread "main" java.lang.NoClassDefFoundError: dateandtime/DateAndTime (wrong name: DateAndTime)
The name however is not wrong.
If I have all the classes in the same directory with no package specified then the .jar file runs fine but as soon as I try to specify a package, even though myJarFile.jar was created I get the error.
Why is that?