ubuntu 下面手动安装jdk
刚才在ubuntu安装jdk和eclipse,感觉主要安装jdk比较麻烦,记录一下笔记以备后面查看
先在官网上下载jdk的tar包:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
一般用浏览器下载一般下载在/home/username/下载这个目录里面
进入这个目录,解压并且把解压后的文件夹放在/opt/java中
1
|
sudo tar -zxvf jdk-7u40-linux-i586.tar.gz -C /opt/java |
接着,要修改/etc/environment像下面这样:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:${JAVA_HOME}/bin" JAVA_HOME="/opt/java/jdk1.7.0_40" JRE_HOME="${JAVA_HOME}/jre" CLASSPATH=".:${JAVA_HOME}/lib:${JRE_HOME}/lib"
接着,要把刚才安装的jdk设为默认的:
sudo update-alternatives --install /usr/bin/java java /opt/java/jdk1.7.0_40/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.7.0_40/bin/javac 300 sudo update-alternatives --install /usr/bin/javap javap /opt/java/jdk1.7.0_40/bin/javap 300 sudo update-alternatives --install /usr/bin/javadoc javadoc /opt/java/jdk1.7.0_40/bin/javadoc 300
好了,现在可以在命令行中输入下面的命令来检查jdk是否安装好了:
1
|
java --version |