JAVA - External JAR files in UNIX | Unix Linux Forums | Programming

  Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

JAVA - External JAR files in UNIX

Programming


Tags
external jar, java, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-08-2008
satish2712 satish2712 is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 11 September 2008, 8:52 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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 ?
Sponsored Links
    #2  
Old 08-08-2008
vino's Avatar
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 9 April 2013, 8:19 AM EDT
Location: Sydney, Down Under
Posts: 2,847
Thanks: 0
Thanked 12 Times in 12 Posts
Quote:
Originally Posted by satish2712 View Post
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 ?
You should set CLASSPATH so that it points to the jar file. Pointing it to the folder will not work.
Sponsored Links
    #3  
Old 08-08-2008
cbkihong cbkihong is offline Forum Advisor  
Advisor
 
Join Date: Sep 2002
Last Activity: 2 May 2012, 10:50 AM EDT
Location: Hong Kong, China
Posts: 1,622
Thanks: 0
Thanked 9 Times in 8 Posts
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.
    #4  
Old 08-08-2008
satish2712 satish2712 is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 11 September 2008, 8:52 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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 :-( ], 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 ?
Sponsored Links
    #5  
Old 08-08-2008
cbkihong cbkihong is offline Forum Advisor  
Advisor
 
Join Date: Sep 2002
Last Activity: 2 May 2012, 10:50 AM EDT
Location: Hong Kong, China
Posts: 1,622
Thanks: 0
Thanked 9 Times in 8 Posts
Try using ":" (colon) instead of ";" (semicolon) as the path separator in your classpath.
Sponsored Links
    #6  
Old 08-08-2008
satish2712 satish2712 is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 11 September 2008, 8:52 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by cbkihong View Post
Try using ":" (colon) instead of ";" (semicolon) as the path separator in your classpath.

that worked

thanks a lot.
Sponsored Links
    #7  
Old 08-08-2008
satish2712 satish2712 is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 11 September 2008, 8:52 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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 ?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compiling all modified Java files in a folder on Unix Annorax Shell Programming and Scripting 1 04-13-2010 05:14 PM
Editing external files heatona Shell Programming and Scripting 0 01-25-2010 11:54 AM
Possible to use a Java app with dll files on Unix-systems Scorp-D UNIX for Dummies Questions & Answers 3 03-29-2007 09:52 AM
Accessing files on external USB drive using UNIX? Slanter UNIX for Dummies Questions & Answers 1 05-30-2006 01:47 AM
Installing External Modem on Unix trinitygirl71 UNIX for Dummies Questions & Answers 3 08-25-2005 04:13 PM



All times are GMT -4. The time now is 09:35 AM.