The Artima Developer Community
Sponsored Link

Java Answers Forum
multiple .jar files in CLASSPATH ?

9 replies on 1 page. Most recent reply: Sep 1, 2003 1:01 AM by joboc ccc

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
joboc ccc

Posts: 4
Nickname: joboc
Registered: Aug, 2003

multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 4:54 AM
Reply to this message Reply
Advertisement
Hi,

I'm trying to run some JAVA code which has a .../lib directory containing 10 jar files.

It seems to work if I:
(1) add the directory to my CLASSPATH and (2) unzip all the jar files
OR
(1) add each jar file individually to my CLASSPATH.

Both ways seem like too much work. Can one reference a whole directory of (zipped) jar files with one CLASSPATH entry ?

Thanks,


David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 7:43 AM
Reply to this message Reply
Lazy bugger!

If a.jar uses b.jar, you can add the following to the manifest file of a.jar:

Class-Path: b.jar

joboc ccc

Posts: 4
Nickname: joboc
Registered: Aug, 2003

Re: multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 8:18 AM
Reply to this message Reply
Ahh, thanks but I prefer the term 'efficient' to lazy.

Anyway, in my situation it is not the jars using each other, but the class files in the code referencing lots of jars (although separately).

Thanks

David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 8:30 AM
Reply to this message Reply
How many jars are we talking about?

joboc ccc

Posts: 4
Nickname: joboc
Registered: Aug, 2003

Re: multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 8:35 AM
Reply to this message Reply
12 jars

Greg

Posts: 18
Nickname: singleton
Registered: Jun, 2003

Re: multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 10:29 AM
Reply to this message Reply
How about starting the app using a shell
script or scripting language.
List the directory and pipe the output into
a system command.

Grant Bremer

Posts: 4
Nickname: gbremer
Registered: Aug, 2003

Re: multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 10:57 AM
Reply to this message Reply
yeah, script that stuff into a startup script. I have shamelessly scammed the code from the tomcat startup scripts for *nix and windows for exactly this purpose.

also, it's a good idea to script this stuff to give you the ability to control the order of the jar files in the CLASSPATH.

Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: multiple .jar files in CLASSPATH ? Posted: Aug 28, 2003 4:17 PM
Reply to this message Reply
Is it not possible to re-jar the 12 Jars again and then put that Jar in the class path? Will this work?

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: multiple .jar files in CLASSPATH ? Posted: Aug 31, 2003 7:34 PM
Reply to this message Reply
You could also create an environment variable which contains all the jar file names separated by semicolons, and then include that environment variable in your classpath.

I've seen several java applications frequently do this such as TOMCAT_HOME, CATALINA_HOME, MYAPPLICATION, etc.

MYAPPLICATION=c:\j2dk1.4.2\myapp\lib\file1.jar;c:\j2dk1.4.2\myapp\lib\fil e2.jar;c:\j2dk1.4.2\myapp\lib\file3.jar;c:\j2dk1.4.2\myapp\lib\file4.jar;c:\j2dk 1.4.2\myapp\lib\file5.jar;c:\j2dk1.4.2\myapp\lib\file6.jar;c:\j2dk1.4.2\myapp\li b\file7.jar;c:\j2dk1.4.2\myapp\lib\file8.jar;c:\j2dk1.4.2\myapp\lib\file9.jar;c: \j2dk1.4.2\myapp\lib\file10.jar;
CLASSPATH=%CLASSPATH%;MYAPPLICATION;

Another standard way is to copy these jar file into the jre\lib\ext folder where no class path change will be needed.

joboc ccc

Posts: 4
Nickname: joboc
Registered: Aug, 2003

Re: multiple .jar files in CLASSPATH ? Posted: Sep 1, 2003 1:01 AM
Reply to this message Reply
Thanks for all the good ideas. My favorite is the environment variable included in the CLASSPATH.

Thanks everyone. This is my first use of this forum and I am impressed !

joboc

Flat View: This topic has 9 replies on 1 page
Topic: Modelling a business rule Previous Topic   Next Topic Topic: Weblogic deployment

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use