LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to add external jars, Java program with Reference Libraries (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-add-external-jars-java-program-with-reference-libraries-686774/)

yuubouna 11-27-2008 11:34 PM

how to add external jars, Java program with Reference Libraries
 
I have a Java program, that reference to external libraries.

for e.q.
Sample.java reference to:
poi-scratchpad-3.5-beta3-20080926.jar

I am not sure where to put the reference library and setting up.
Do I need to add that also in Path settings?


Cheers,
jackie

yuubouna 11-28-2008 03:15 AM

I made my java programs run by including unzip jar files of:
poi-3.5-beta3-20080926.jar, in order to reference the class files my Java program required.


My directory structured looks like the ff:
/home/me/poi
[org] - directory where poi-3.5-beta3-20080926.jar unzip files where located
Sample.java - java files that reads the

But I think this setting not flexible.

Anybody knows how to make a reference to a jar files?

jackie

jay73 11-28-2008 03:56 AM

You need to place the jar on your classpath. To do so, open your .(bash)_profile or your /etc/profile and add
export CLASSPATH=/path/to/jar:$CLASSPATH
You will then need to source the file in question or log out and back in.

yuubouna 11-30-2008 09:19 PM

Hello Jay, thanks!
Yes, exactly that`s what I did.

I found that my classpath settings mistakes in calling the Apache Poi JAR files.
Changing it in order to call the JARs solved my problems.

in my .bash_profile, I append the following:
export APACHE_POI=/home/me/poi-3.5-beta3 ---> (Here where JAR`S Files are located.)
export PATH=$APACHE_POI:$PATH
export CLASSPATH=$CLASSPATH:$APACHE_POI

checking to see if its set:
set
then,

....
CLASSPATH=:/usr/local/jdk1.6.0_10/lib:/home/me/poi-3.5-beta3
PATH=/home/me/poi-3.5-beta3:/usr/local/jdk1.6.0_10/bin
....

APACHE_POI classpath where now setup, properly.
I don`t need either the unzip files of the Jars located in /home/me/poi-3.5-beta3.



(^-^)/ Cheers,
jackie


All times are GMT -5. The time now is 04:57 AM.