On Apr 16, 1:12 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article
<13dae324-a0b1-445e-b644-c7400c19d...@k2g2000yql.googlegroups.com>,
Philipp <djb...@gmail.com> wrote:
[...]
Note PrintTest is in default package.
[...]
Now executing:
$ java -cp Printer.jar PrintTest
Exception in thread "main" java.lang.NoClassDefFoundError: PrintTest
[...]
What am I doing wrong?
Your classpath omits the current directory:
java -cp .:Printer.jar PrintTest
Thanks for the ansnwer, but this does not solve the problem! I still
get
$ java -cp .:Printer.jar PrintTest
Exception in thread "main" java.lang.NoClassDefFoundError: PrintTest
[...]
I noticed that when compiling:
$ javac -cp Printer.jar PrintTest.java
I end up with a file MyPrinter.class in the folder. This is the one
which should be (and is) in the jar. Where is that file coming from?
If I compile with the classpath set to the current folder as well, I
get a compile error:
$ javac -cp .:Printer.jar PrintTest.java
PrintTest.java:1: package mytest does not exist
import mytest.MyPrinter;
^
PrintTest.java:4: cannot find symbol
symbol : class MyPrinter
location: class PrintTest
MyPrinter ps = new MyPrinter();
^
PrintTest.java:4: cannot find symbol
symbol : class MyPrinter
location: class PrintTest
MyPrinter ps = new MyPrinter();
^
3 errors
Should the manifest in the jar contain more details (it's basically
empty now)?