首頁 > 軟體

Linux下切換JDK的指令碼

2020-06-16 17:38:48

Linux下切換JDK的指令碼,以切換jdk6和jdk7為例,指令碼程式碼如下:

#!/bin/sh  
#usage: . swith_jdk.sh [argvs] 
jdk6_home=/usr/lib/jvm/jdk1.6.0_43  
jdk7_home=/usr/lib/jvm/java-7-openjdk-amd64 
case $1 in  
j6)  
export JAVA_HOME=$jdk6_home  
;;  
j7)  
export JAVA_HOME=$jdk7_home  
;;  
*)  
export JAVA_HOME=$jdk7_home  
;;  
esac
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH  
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

IT145.com E-mail:sddin#qq.com