Friday, June 13, 2014

Import *.jar file and *.class files for java program

For example, I wish to include a *.jar file

I can edit the ~/.bash_profile to include the classpath as follows:

  1 #. /opt/sge/settings.sh
  2 PATH=$PATH:/data/home/hufeng/tool/bowtie-0.12.9/
  3 PATH=$PATH:/data/home/hufeng/tool/ghostscript-linux/
  4 PATH=$PATH:/data/home/hufeng/tool/homer/bin/
  5  export CLASSPATH=/data/home/hufeng/tool/ChIAPETtool/:/data/home/hufeng/tool/ChIAPETtool/commons-cli-1.2/commons-cli-1.2.jar

Or
I can use -cp (--classpath) as follows:

javac   -cp   com/comx.jar   yy.java

if want include other class path, use ":" to divide, e.g.:

javac -cp .:commons-cli-1.2/commons-cli-1.2.jar LGL/chiapet/LinkerFilter.java


This is the online version, not sure if it works.

  1 #!/bin/sh
  2 export JAVA_HOME=/var/lib/java
  3 export PROJECT_HOME=/home/runner/***/WebRoot/WEB-INF
  4 export PATH=$JAVA_HOME/jre/bin:$PATH
  5 export CLASSPATH=$JAVA_HOME/jre/lib:$PROJECT_HOME/classes:$CLASSPATH
  6 # add all the jar
  7 for loop in `ls $PROJECT_HOME/lib/*.jar`;do
  8   export CLASSPATH=${loop}:${CLASSPATH}
  9   done;

No comments:

Post a Comment