$ sudo apt-get install openjdk-7-jre
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jdk
/下面参考即可//
0. 使用env 发现编译android 需要的版本书java-7-openjdk-amd64/bin:
<pre name="code" class="plain">fuxuan@ubuntu:/usr/lib/jvm$ env
ANDROID_DEV_SCRIPTS=/home/fuxuan/WORKING_DIRECTORY/development/scripts:/home/fuxuan/WORKING_DIRECTORY/prebuilts/devtools/tools:/home/fuxuan/WORKING_DIRECTORY/external/selinux/prebuilts/bin
XDG_VTNR=7
XDG_SESSION_ID=c2
ANDROID_PRE_BUILD_PATHS=/usr/lib/jvm/<strong>java-7-openjdk-amd64/bin:</strong>
1. java se 7 下载地址
http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html
2. 将 java 7 安装到该目录 下面/usr/lib/jvm/
3. 配置环境变量
Setting the "JAVA_HOME" environment variable
To set the JAVA_HOME
environment variable, which is needed for some programs, first find out the path of your Java installation:
sudo update-alternatives --config java
It returns something like:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode
Press enter to keep the current choice[*], or type selection number:
The path of the installation is for each:
-
/usr/lib/jvm/java-7-oracle
-
/usr/lib/jvm/java-6-openjdk-amd64
-
/usr/lib/jvm/java-7-oracle
Copy the path from your preferred installation and then edit the file /etc/environment
:
sudo nano /etc/environment
In this file, add the following line (replacing YOUR_PATH by the just copied path):
JAVA_HOME="YOUR_PATH"
That should be enough to set the environment variable. Now reload this file:
source /etc/environment
Test it by executing:
echo $JAVA_HOME
If it returns the just set path, the environment variable has been set successfully. If it doesn't, please make sure you followed all steps correctly.
$ sudo apt-get install openjdk-7-jre
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jdk