http://blog.csdn.net/foxbryant/article/details/51813685java
sudo gedit /etc/profile
或者bash
gedit ~/.bashrc #set java environment export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_25 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
保存退出,輸入如下命令使之當即生效。jvm
配置默認JDK:測試
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_25/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_25/bin/javac 300 //後面兩項能夠不配置 sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.8.0_25/bin/javah 300 sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8.0_25/bin/jar 300 //版本切換命令 sudo update-alternatives --config java sudo update-alternatives --config javac
測試.net
java -version javac -version