Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

Java Classpath - Simple Question

Thread view: 
RalphLeon - 03 Aug 2007 18:00 GMT
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
RalphLeon - 03 Aug 2007 18:05 GMT
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/tutorial/deployment/jar/downman.html

Why is this process so confusing!?
David Zimmerman - 03 Aug 2007 19:24 GMT
> Every year or so I do a project with java.... and every year I come
> into the same problem.
[quoted text clipped - 8 lines]
> I call:
> $ java -classpath .:lib/Foo.jar -jar Bar.jar

The -jar option trumps the -classpath option.  The -classpath is ignored.
Mike Schilling - 03 Aug 2007 19:56 GMT
>> Every year or so I do a project with java.... and every year I come
>> into the same problem.
[quoted text clipped - 11 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.