Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java Classpath - Simple Question

Reply
Thread Tools

Java Classpath - Simple Question

 
 
RalphLeon
Guest
Posts: n/a
 
      08-03-2007
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

 
Reply With Quote
 
 
 
 
RalphLeon
Guest
Posts: n/a
 
      08-03-2007
For the love of god I just figured it out:

In the jar's manifest file add:

Class-Path: jar1-name jar2-name directory-name/jar3-name

For more info:
http://java.sun.com/docs/books/tutor...r/downman.html

Why is this process so confusing!?



 
Reply With Quote
 
 
 
 
David Zimmerman
Guest
Posts: n/a
 
      08-03-2007


RalphLeon wrote:
> 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.
 
Reply With Quote
 
Mike Schilling
Guest
Posts: n/a
 
      08-03-2007
David Zimmerman wrote:
> RalphLeon wrote:
>> 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.


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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.classpath file instead of the CLASSPATH Environment variable. dontspammenow@yahoo.com Java 2 03-02-2008 08:19 AM
problem compiling project, classpath in xml ".classpath" "<classpathentry...>" jameshanley39@yahoo.co.uk Java 2 03-02-2007 12:37 PM
simple classpath question` cppaddict Java 2 09-24-2006 05:47 AM
while using javac -classpath some.jar some.java (Where does classpath get stored?) Gabe Java 3 08-27-2004 07:02 PM
CLASSPATH, -cp and -classpath misunderstanding? Flip Java 3 02-09-2004 10:09 PM



Advertisments