ubuntu配置 Java SE 1.6
今天编译android 4.0时提示如下错误:
You are attempting to build with the incorrect version of java.
Your version is: java version "1.6.0_22".
The correct version is: Java SE 1.6.
查了一下现在已安装的java:
java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.4) (6b22-1.10.4-0ubuntu1~11.04.2)
OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)
解决办法如下:
1.从java官方地址http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download-1501634.html 下载Java SE Development Kit 6 Update 31文件,文件名是jdk-6u31-linux-i586.bin。
2.移到/opt目录下执行
chmod a+x jdk-6u27-linux-i586.bin
sudo ./jdk-6u27-linux-i586.bin
添加环境变量:
sudo gedit /etc/profile
在文件最后添加
#set java environment
export JAVA_HOME=/opt/jdk1.6.0_27
export JRE_HOME=/opt/jdk1.6.0_27/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
最后使环境变量生效:
. /etc/profile
配置完后,再查看jdk版本:
$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)
-------------
ps: 只在当前会话生效可以只export就好
可以修改sudo vi ~/.bashrc 这样会自动导入java的环境变量
#set java environment
export JAVA_HOME=/home/sunshine/jdk1.6.0_45
export JRE_HOME=/home/sunshine/jdk1.6.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
Donate:)
以上是 ubuntu配置 Java SE 1.6 的全部内容, 来源链接: utcz.com/z/392736.html