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 / December 2006

Tip: Looking for answers? Try searching our database.

Help with executing a jar file

Thread view: 
Bryan - 15 Dec 2006 18:06 GMT
Hello all,

I'm having trouble executing a jar file I created using Eclipse.  I
have two projects set up in Eclipse... one with all the main source
code (no Main classes) and another with a main class that utilizes code
from the other project.  I created a jar of the first project and added
the jar to the build path of the second project and I can run the Main
class in the second project no problem.  I then created a jar file of
the second project and included the Main class in the manifest.  When I
try to execute this jar file from the command line I get the following
error:

% java -cp SourceCode.jar -jar Executable.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
/path/to/some/package/class

Both the source jar and the executable jar are in the current working
directory.  Any clues as to why this isn't working?

Thanks!
Andrew Thompson - 15 Dec 2006 18:22 GMT
...
> % java -cp SourceCode.jar -jar Executable.jar

Note the -cp option is ignored when the -jar
option is specified.

Andrew T.
Bryan - 15 Dec 2006 18:49 GMT
So how do I tell it to include SourceCode.jar in the classpath so
Executable.jar has access to it?

> Bryan wrote:...
>
> > % java -cp SourceCode.jar -jar Executable.jarNote the -cp option is ignored when the -jar
> option is specified.
>
> Andrew T.
Knute Johnson - 15 Dec 2006 19:29 GMT
> So how do I tell it to include SourceCode.jar in the classpath so
> Executable.jar has access to it?
[quoted text clipped - 5 lines]
>>
>> Andrew T.

You have to specify it in the manifest file.

http://rabbitbrush.frazmtn.com/classpath.html#jar

Signature

Knute Johnson
email s/nospam/knute/

Bryan - 15 Dec 2006 22:44 GMT
Thanks, that worked great!!

On Dec 15, 12:29 pm, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> > So how do I tell it to include SourceCode.jar in the classpath so
> > Executable.jar has access to it?
[quoted text clipped - 12 lines]
> Knute Johnson
> email s/nospam/knute/


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.