Java Classpath - Simple Question

R

RalphLeon

Every year or so I do a project with java.... and every year I come
into the same problem.

I have a jar file I want to use with my application, say Foo.jar in
the "lib" directory.

My application is a jar file, say Bar.jar put together by ant.

I want to use some utility in Foo.jar

I call:
$ java -classpath .:lib/Foo.jar -jar Bar.jar

and I get a "Exception in thread "main"
java.lang.NoClassDefFoundError: " related to the class I want in
Foo...

In my main file I did a

"include Foo.*;"

and everything *compiles* just fine.... I can post specific code if it
will help.... I figure I am just forgetting something silly...

At Your Mercy,
Ralph
 
D

David Zimmerman

RalphLeon said:
Every year or so I do a project with java.... and every year I come
into the same problem.

I have a jar file I want to use with my application, say Foo.jar in
the "lib" directory.

My application is a jar file, say Bar.jar put together by ant.

I want to use some utility in Foo.jar

I call:
$ java -classpath .:lib/Foo.jar -jar Bar.jar

The -jar option trumps the -classpath option. The -classpath is ignored.
 
M

Mike Schilling

David said:
The -jar option trumps the -classpath option. The -classpath is
ignored.

Though no error (or even warning) saying "-classpath is not valid here" is
produced. That would make things far too straightforward.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top