Ubuntu下jdk的安装以及Java环境的配置
到官网下载jdk,在Java SE Development Kit 7uXX里面,把Accept License Agreement 打勾,这样才能下载jdk,然后我们选择对应的Ubuntu版本下载,如果不知道自己该下哪个版本,可以用getconf LONG_BIT看看自己是几位的。
sudo mkdir /usr/local/java
sudo cp jdk-7u40-linux-i586.tar.gz /usr/local/java
cd /usr/local/java
sudo tar -zxvf jdk-7u40-linux-i586.tar.gz
sudo vim ~/.bashrc
#java
export JAVA_HOME=/usr/local/java/jdk1.7.0_40
export JRE_HOME=/usr/local/java/jdk1.7.0_40/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=/usr/local/java/jdk1.7.0_40/bin:$PATH
source ~/.bashrc
sudo update-alternatives --install /usr/bin/java java /usr/local/java/jdk1.7.0_40/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.7.0_40/bin/javac 300
sudo update-alternatives --install /usr/bin/javap javap /usr/local/java/jdk1.7.0_40/bin/javap 300
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/local/java/jdk1.7.0_40/bin/javadoc 300
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode)
javac test.java 编译文件
java HelloWorld 执行