Making our way to the jars...

R

Rico

D:\program files\Eclipse\workspace\FolderMonitor>java -cp D:\activation.jar;D:\m
ail.jar;D:\log4j-1.2.8.jar -jar folder*


Am I doing something wrong with the above command?
The 3 jars are in D:\ (of course) but I get NoClassDefFoundError:
javax/mail/Address

I started off with them all in the same folder as the jar I'm trying to
run. That also gave NoClassDefFoundError

When I move the jars to jre\lib\ext, things work fine.

I came across Invoker on Dawid Weiss's website and I do this:

java -jar Invoker.jar -cpalljars .\ -cpdir .\ <fully qualified classname>

Things work fine.

Why would both using the absolute path to the jars and placing them
in the current working directory still cause NoClassDefFoundError?

Rico.
 
O

Oscar kind

Rico said:
D:\program files\Eclipse\workspace\FolderMonitor>java -cp D:\activation.jar;D:\m
ail.jar;D:\log4j-1.2.8.jar -jar folder*


Am I doing something wrong with the above command?
The 3 jars are in D:\ (of course) but I get NoClassDefFoundError:
javax/mail/Address

Yes: if the -jar switch is used, the classpath switches (-classpath and
-cp) are ignored. So is the CLASSPATH variable.

This is documented in the manual, right after the most elaborate
explanation of the -jar switch (not the first). So if you read the manual
instead of just skimming it, it's unfortunately likely that you missed
it.

There is a solution however: If you know the location of activation.jar
and mail.jar relative to your own .jar file, you can make it work by
adding one or more "Class-Path:" headers to the manifest.

See here for more information:

http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Main Attributes
 
R

Rico

Yes: if the -jar switch is used, the classpath switches (-classpath and
-cp) are ignored. So is the CLASSPATH variable.

This is documented in the manual, right after the most elaborate
explanation of the -jar switch (not the first). So if you read the
manual instead of just skimming it, it's unfortunately likely that you
missed it.

There is a solution however: If you know the location of activation.jar
and mail.jar relative to your own .jar file, you can make it work by
adding one or more "Class-Path:" headers to the manifest.

See here for more information:

http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Main Attributes

All right. Thanks a lot for the pointers and the clarification.
I'll stick with Invoker.jar which works like a charm for me for now.

Rico.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top