MyClassWithMainMethod.java uses classes of someJar.jar.
If I call:
java -cp someJar.jar MyClassWithMainMethod
I get the exception:
Exception in thread "main" java.lang.NoClassDefFoundError: MyClassWithMainMethod
Caused by: java.lang.ClassNotFoundException: MyClassWithMainMethod
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
But when I set the CLASSPATH to my jar manually
export CLASSPATH=:/path/to/someJar.jar
it works calling
java MyClassWithMainMethod
What am I doing wrong?