2. 设置环境变量:修改/etc/profile 文件,
执行命令: sudo gedit /etc/profile
在末尾添加:
export JAVA_HOME=/opt/jdk1.7.0_21export CLASSPATH=.:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
3.将所安装的jdk设置成默认的java版本(原来的openJDK):
执行代码:
sudo update-alternatives --install /usr/bin/java java /opt/jdk1.7.0_21/bin/java 300 &&
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_21/bin/javac 300 &&
sudo update-alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_21/bin/jar 300 &&
sudo update-alternatives --install /usr/bin/javah javah /opt/jdk1.7.0_21/bin/javah 300 &&
sudo update-alternatives --install /usr/bin/javap javap /opt/jdk1.7.0_21/bin/javap 300