File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes setting multiple jar file when running Java Class from Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "setting multiple jar file when running Java Class from Linux" Watch "setting multiple jar file when running Java Class from Linux" New topic
Author

setting multiple jar file when running Java Class from Linux

Ajoo Bar
Greenhorn

Joined: Mar 28, 2011
Posts: 28
I am running a stand alone java class on a linux prompt, the java class has reference to 2 different classes in jar file
I am running this command

java -classpath /local/home/test/lib/commons-httpclient.jar:commons-logging.jar:. TestClass

I am running this command from the directory where I have TestClass. But it is not finding a class which is in commons-logging.jar

ANy help will really be appriciated
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16482
    
    2

That would mean that commons-logging.jar is not in your current working directory. Perhaps it's in the same directory as commons-httpclient.jar? If so, then you should say that in your classpath.
Nishanth Thomas
Greenhorn

Joined: Sep 08, 2011
Posts: 7

By Nishanth Thomas ISG Bangalore

try this
First check your class path
by

echo $CLASSPATH
if not set

CLASSPATH=".:/usr/java/jdk1.6.0_05/bin"

and complie like this which takes all jar in the folder or give path

javac -cp :\* test.java

then run
java -cp :\* test

Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 319
Nishanth Thomas wrote:
if not set

CLASSPATH=".:/usr/java/jdk1.6.0_05/bin"

and complie like this which takes all jar in the folder or give path

javac -cp :\* test.java

then run
java -cp :\* test


There are two things wrong with this
1. The JDK bin directory does not contain any jar files or classes so does not need to be in the CLASSPATH. You probably do need it in your PATH environment variable.
2. There is no point in setting a CLASSPATH environment variable if you are going to use the -cp option, as this will cause the environment variable to be ignored.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32611
    
    4
In fact, setting a system classpath usually does more harm than good. I recommend, as well as following SB’s good advice, you delete that classpath as being completely unnecessary.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: setting multiple jar file when running Java Class from Linux
 
Similar Threads
creating and executing a jar file
Class-Path Limits in Jar Manifest Files
I created an executable jar file when i execute it i am getting errors
errors running -Head First Servlets and JSP- example beerStruts
Java program to Login a website using url and to download a file