在安装android on openwrt是出现错误:
[cpp] view plain copy print ?
- build/core/config.mk:271:
- *** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com. Stop.
build/core/config.mk:271:
*** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com. Stop.
需要安装JDK6!
一 第一种方法:
输入下面的命令
[cpp] view plain copy print ?
- sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java6-jdk
如果不能下载安装JDK6,则通过第三方地址获取此jdk6,写入该文件可以使运行安装命令时有地址去下载:
[cpp] view plain copy print ?
- sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
- sudo add-apt-repository "deb http://archive.canonical.com/ubuntu maverick partner"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository "deb http://archive.canonical.com/ubuntu maverick partner"
或者手动打开 /etc/apt/sources.list添加:
[cpp] view plain copy print ?
- deb http:
- deb http:
deb http://archive.canonical.com/ lucid partner
deb http://archive.canonical.com/ubuntu maverick partner
随后更新repository:
[cpp] view plain copy print ?
- sudo apt-get update
sudo apt-get update
安装:
[cpp] view plain copy print ?
- sudo apt-get install sun-java6-jdk
sudo apt-get install sun-java6-jdk
注意安装完后在设定JDK的时候,终端无法动弹,按下Tab键,接下来按照提示……
二 手动安装
如果上面方法不行,则要下载手动安装jdk6,下载地址:
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html
http://download.oracle.com/otn/java/jdk/6/jdk-6-linux-i586.bin
jdk5下载地址:
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html
http://download.oracle.com/otn/java/jdk/1.5.0_22/jdk-1_5_0_22-linux-i586.bin
下面以安装jdk6为例,如果安装的是jdk5,步骤相同。
首先,从http://java.sun.com中下载jdk,我的版本是jdk-6-linux-i586.bin,我下载的是bin文件,我将下载的jdk-6-linux-i586.bin文件置于/usr/lib/jvm/java中。
然后修改bin文件权限,使其可执行,在shell中执行:
[cpp] view plain copy print ?
- sudo chmod u+x /usr/lib/jvm/java/jdk-6-linux-i586.bin
sudo chmod u+x /usr/lib/jvm/java/jdk-6-linux-i586.bin
执行下面命令,将会出现字幕,持续按回车键,直至屏幕显示要求输入yes/no,此时输入y回车,将会把jdk解压到文件夹,得到jdk1.6.0_12目录。
[cpp] view plain copy print ?
- sudo /usr/lib/jvm/java/jdk-6-linux-i586.bin
sudo /usr/lib/jvm/java/jdk-6-linux-i586.bin
此时,jdk已安装完毕。
下面进行配置,在environment中修改,
[cpp] view plain copy print ?
- sudo vi /etc/environment
sudo vi /etc/environment
添加如下部分
[cpp] view plain copy print ?
- PATH="......:/usr/lib/jvm/java/jdk1.6.0/bin"
- CLASSPATH=.:/usr/lib/jvm/java/jdk1.6.0/lib
- JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0
PATH="......:/usr/lib/jvm/java/jdk1.6.0/bin"
CLASSPATH=.:/usr/lib/jvm/java/jdk1.6.0/lib
JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0
或者直接在/etc/profile中添加:(推荐使用)
[cpp] view plain copy print ?
- sudo vi /etc/profile
sudo vi /etc/profile
[cpp] view plain copy print ?
- #JAVAEVIRENMENT
- export JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_34
- export JRE_HOME=$JAVA_HOME/jre
- export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
- export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
#JAVAEVIRENMENT
export JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_34
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
设置环境变量(设置环境变量的方法很多,不一一列举)
[cpp] view plain copy print ?
- sudo source ~/.bashrc
sudo source ~/.bashrc
由于ubuntu中可能会有默认的jdk,如openjdk,所以,为了使默认使用的是我们安装的jdk,还要进行如下工作。
通过这一步将我们安装的jdk加入java选单,执行:
[cpp] view plain copy print ?
- sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0/bin/java 300
- sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0/bin/javac 300
- sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java/jdk1.6.0/bin/javah 300
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0/bin/javac 300
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java/jdk1.6.0/bin/javah 300
然后执行,通过这一步选择系统默认的jdk:
[cpp] view plain copy print ?
- sudo update-alternatives --config java
- sudo update-alternatives --config javac
- sudo update-alternatives --config javah
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javah
这样,再在shell中输入,就会显示系统使用的java是sun的java:
[cpp] view plain copy print ?
- java -version
java -version
参考:
http://forum.ubuntu.org.cn/viewtopic.php?t=183803