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 / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

problem with external JARs

Thread view: 
Abs - 30 May 2004 23:41 GMT
Hi!

  I'm developing a Java app using the Eclipse IDE. My app uses some
external JARs to work. The app runs fine from the IDE, I suppose Eclipse
takes care of all the dependencies. But, when I try to run it from the
command line, it cannot find the JARs. Is there a way to run a Java app
that depends on other JARs without having to alter the classpath
variable to add all the external libraries that an app uses ?

Regards

Signature

Abs

Ryan Stewart - 30 May 2004 23:59 GMT
> Hi!
>
[quoted text clipped - 6 lines]
>
> Regards

Please do not multipost.

That's the whole purpose of the classpath. Otherwise how does Java know
where to find the classes it's looking for?
VisionSet - 31 May 2004 00:15 GMT
> > Hi!
> >
[quoted text clipped - 4 lines]
> > that depends on other JARs without having to alter the classpath
> > variable to add all the external libraries that an app uses ?

> Otherwise how does Java know where to find the classes it's looking for?

It looks in the jre/lib/ext directory.

Put your JARs there.  This maybe a little trickier if you are deploying this
over many clients, and then again maybe not.

Signature

Mike W

Roedy Green - 31 May 2004 01:02 GMT
>Is there a way to run a Java app
>> that depends on other JARs without having to alter the classpath
>> variable to add all the external libraries that an app uses ?

yes, you can specify the jars or the classpath on the command line.
you can also put jars in the ext directory.

See http://mindprod.com/jgloss/classpath.html

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

Oscar kind - 31 May 2004 23:40 GMT
>   I'm developing a Java app using the Eclipse IDE. My app uses some
> external JARs to work. The app runs fine from the IDE, I suppose Eclipse
> takes care of all the dependencies. But, when I try to run it from the
> command line, it cannot find the JARs. Is there a way to run a Java app
> that depends on other JARs without having to alter the classpath
> variable to add all the external libraries that an app uses ?

When you put your classes in a JAR file, that JAR file has a manifest. You
can use the default manifest, and add two headers to it to create a
"self-contained" application:
    Main-Class: package.to.MainClass
    Class-Path: library1.jar library2.jar

The Class-Path header contains relative URL's to the JAR files. IN the
example above, it looks for the JAR files it depends on in the current
directory.

As pointed out by others, you can also place the JAR files you depend upon
in the lib/ext subdirectory of the directory the JRE resides in.
Personally, I prefer the first approach however; it's easier to uninstall
(as no other application will use your files).

Oscar

Signature

Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2



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.