开发者

How to install Java 5 SDK for building Android Source?

开发者 https://www.devze.com 2023-03-28 18:52 出处:网络
According to Android Developer website, the following is the process to install Java 5 SDK $ sudo add-apt-repository \"deb http://archive.ubuntu.com/ubuntu dapper main multiverse\"

According to Android Developer website, the following is the process to install Java 5 SDK

$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse"
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main     multiverse"
$ sudo apt-get update
$ sudo apt-get 开发者_JS百科install sun-java5-jdk

But, when I try to execute the last two commands I get an error -- the reason being the URL added to the repository by the first two commands is inaccessible. I am using Ubuntu 11.04. In that case, how do I execute Java 5 SDK?

If I install Java 5 SDK from http://java.sun.com, then I get error while *make*ing Android Sources due to the following reason

package com.sun.javadoc does not exist

Please suggest me a suitable way


You can try using the hardy repository. This works fine with Ubuntu 10.04 32bit.

$ sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse" 
$ sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse"
$ sudo apt-get update 
$ sudo apt-get install sun-java5-jdk

To confirm if successfully installed run.

$ sudo update-java-alternatives -l

To switch the Java version, run.

$ sudo update-java-alternatives
$ sudo update-java-alternatives -s java-1.5.0-sun

Then confirm if switched successfully, run.

$ java -version


If you install the Java 5 SDK from Oracle (downloading the .bin is my preferred method), when you are done, you will need to sudo edit your etc-alternatives configuration after the installation. You can tell which one your referencing by the command "which java" or "which javaw".

For Oracle JDK, it might be something like:

# update-alternatives --install "/usr/java/jdk1.6.0_26/java" "java" "/usr/java/default/bin/java" 3
# update-alternatives --install "/usr/java/jdk1.6.0_26/javac" "javac" "/usr/java/default/bin/javac" 3

If you don't use "update-alternatives", you can do it manually in /etc/alternatives/java, at minimum, you will need sudo access to update the java symbolic link so that the java in your path goes to the right location. Of course, there are other complications to this that you need to watch out for.

Because I like to be pure Oracle Java, I usually use "Oracle Solaris 11 Express" as my linux distro for java development.


11.04 is called natty narwhal; dapper is from a while ago. java 5 is really old too. you should be using java 6 or 7 now.

0

精彩评论

暂无评论...
验证码 换一张
取 消