My directory structure is like this:
> makefile
> app.jar
> src
> Main.java
> Main.class
> some other classes
> manifest.txt
I compile from the makefile with these commands:
javac src/*.java
jar cvfm app.jar src/manifest.txt src/*.class
manifest.txt
contains this:
Main-Class: Main
When I run java -jar app.jar
from the top directory I get this error:
$ java -jar app.jar
Exception in thread "main" java.lang.NoClassDefFoundError: Main
Caused by: java.lang.ClassNotFoundException: Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Main. Program will exit.
I tried changing the manifest to say Main-Class: src.Main
but that didn't work either. This is probably very simple but I'm finding Google doesn't provide any simple solutions.