JAVA - External JAR files in UNIX

Hi,

I have to run my JAVA programs in UNIX server. The java program uses some external jar files for compiling. I have set the classpath to the folder where all the jar files are present using EXPORT classpath command.

But when i compile, it shows errors.. saying that the classes relating to the jar files are not found.

which means it is not recognising the jar files !!!

Please let me know how to make this compile ? :frowning:

You should set CLASSPATH so that it points to the jar file. Pointing it to the folder will not work.

You have to name all the JARs on the classpath. Just putting the directory containing the JARs on the classpath will NOT work.

However, if you use JDK 6, you can use a '*' wildcard with the '-classpath' argument to select all jars in a given directory. This feature is not available in earlier JDK versions (5.0 or 1.x).

Setting the class path

Look at the "Understanding class path wildcards" section.

Apache Ant - Welcome makes Java application building and managing classpath sort of an easy task.

Thanks, That worked fine for one external jar file. But wen i am using more than one external jar file, i get the following error.

Note: my java program Inbound.java needs 2 jar files jms.jar and com.ibm.mq.jar
and i have jdk 1.4 installed in UNIX server [cant change to JDK 6 :frowning: ], so i have to go with specifying all the jar files path in command prompt

/u/up11/sample/request:>javac -classpath /u/up11/sample/jarfiles/jms.jar;/u/up11
/sample/jarfiles/com.ibm.mq.jar Inbound.java

javac: no source files

/u/up11/sample/jarfiles/com.ibm.mq.jar: FSUM9209 cannot execute: reason code = 5b4c0002: EDC5111I Permission denied.

what is the reason for this error ?

Try using ":" (colon) instead of ";" (semicolon) as the path separator in your classpath.

that worked :b:

thanks a lot. :slight_smile:

Hi,

there is one more problem related to this. When i give javac command with -classpath options, it is compiling and working fine. But the cursor does not come to the command prompt again, unless i press the ENTER key.

i wrote a sample script file to make this more clear

script file
echo before compiling
javac -classpath /full/path/a.jar:/full/path/b.jar classname.java
echo after compiling

the output i get in cmd prompt when i run the script file is as follows


cmdpmt>: before compiling


only after i press ENTER key i get


cmdpmt>: before compiling
after compiling

cmdpmt>:

what is the reason for this ? and how to resolve it, so that i can get the output without pressing ENTER key ?

I cannot reproduce this behaviour myself with the JDK6 compiler I have with an empty hello world program. Maybe it's specific to your program?

i have jdk1.4 installed in my server. will the problem be because of jdk version ??