AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

problem with external JARs

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Abs
Guest





PostPosted: Sun May 30, 2004 10:41 pm    Post subject: problem with external JARs Reply with quote



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

--
Abs
Back to top
Ryan Stewart
Guest





PostPosted: Sun May 30, 2004 10:59 pm    Post subject: Re: problem with external JARs Reply with quote



"Abs" <abs (AT) terra (DOT) com> wrote

Quote:
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

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?



Back to top
VisionSet
Guest





PostPosted: Sun May 30, 2004 11:15 pm    Post subject: Re: problem with external JARs Reply with quote




Quote:
"Abs" <abs (AT) terra (DOT) com> wrote

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 ?

"Ryan Stewart" <zzanNOtozz (AT) gSPAMo (DOT) com> wrote


Quote:
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.

--
Mike W



Back to top
Roedy Green
Guest





PostPosted: Mon May 31, 2004 12:02 am    Post subject: Re: problem with external JARs Reply with quote

On Sun, 30 May 2004 17:59:41 -0500, "Ryan Stewart"
<zzanNOtozz (AT) gSPAMo (DOT) com> wrote or quoted :

Quote:
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

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

Back to top
Oscar kind
Guest





PostPosted: Mon May 31, 2004 10:40 pm    Post subject: Re: problem with external JARs Reply with quote

Abs <abs (AT) terra (DOT) com> wrote:
Quote:
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

--
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

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.