编译android 源代码

整体步骤与要求参考 http://source.android.com/source/initializing.html

环境搭建:

1.安装 linux ubuntu 12.4

2.安装samba 安装配置参考 http://wiki.ubuntu.org.cn/Samba

3.安装java jdk 方法:

$ sudo add-apt-repository " deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse" 适用于ubuntu 12.4 
$ sudo apt-get update 
$ sudo apt-get install sun-java6-jdk

 

jdk 手工安装方法参考:

Oracle 官方bin安装包

此外可以用Linux上通用的bin包安装,下载官方bin包,终端下面安装解压,然后修改环境变量指向那个jdk便可。

设置环境变量,修改.bashrc或.profile,参考自己系统解压的路径改改。

export JAVA_HOME=/home/user/jdk1.6.0_21/
export PATH=$JAVA_HOME/bin:$PATH
export classPath=/home/user/jdk1.6.0_21/

查看java版本

qii@ubuntu:~$ java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)

 

Oracle Java 7

 

Oracle has declared Java 7 to be fit for general use.

Currently there are no .deb packages available for Oracle Java 7. The raw binaries (without installer) can be downloaded directly from Oracle (Oracle Java download page).

Installing Oracle Java 7 by a script or from the command line

 

You can install the newest and secure Oracle (Sun) Java 7 by a script (JRE only) or by a command line method. Both are easy to apply.

Script (JRE only)

 

Only supports Oracle (Sun) Java 7 JRE (which covers the needs of 99 % of all computer users). It pulls the packages from Oracle's website and installs them, comparable to the way Adobe Flash Player is being installed. Plus it adds a dedicated repository, from which you'll receive updates automatically.

Command line methods

 

Do-it-yourself methods, but very easy to apply (basically: you copy/paste some terminal commands).

Using webupd8.org's method has a great benefit in that the package will be updated as Oracle releases Java updates, which means that there will be no need to keep track of updates and reinstall them manually.

A note (hopefully temporary) about the Eugene San PPA for those who are attempting to use it and are having issues: As of the time of this entry, the eugenesan/java PPA is broken. If you have attempted to use it, you may do the following to remove it and use webupd8.org's PPA method (above) instead

 sudo apt-get purge oracle-java7-installer*
 sudo apt-get install ppa-purge
 sudo ppa-purge ppa:eugenesan/java
 sudo apt-get clean
 sudo apt-get update

 

If the preceding does not work, you may try the following more aggressive method. Be aware, however, that it uses the rm command, which will completely remove files immediately and permanently from an important directory. Be extremely cautious.

sudo rm /var/lib/dpkg/info/oracle-java7-installer*
sudo apt-get purge oracle-java7-installer*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update

 

There is also an RFE opened on Oracle bugtracker to provide the debian package/installer for Java 7. Please consider voting for this RFE.

Oracle (Sun) Java 6

 

WARNING: Oracle Java 6 had reached its end of life in November 2012. There is at least one severe known vulnerability in this version, and since Java 6 is neither supported by Canonical nor Oracle, there may be many more! You should really not install this unless you have a specific need to do so. It is recommended that users either migrate to OpenJDK, or install Oracle Java 7. 

Oracle (Sun) Java 6 is no longer available to be distributed by Ubuntu, because of license issues. 

Deprecated information about the installation of Oracle Java 6:

JDK or JRE

 

Downloads the Java binary installers from Oracle, builds the .deb packages locally on your computer and then installs them. Packages are compatible with the “official” Ubuntu ones and will upgrade Java 6 that was previously installed from packages.

You can find the script and full usage instructions on github.

(since version 0.2.3 it also works with java 7 using -7 optional parameter).

Another instruction it works for Ubuntu 12.04.

Manual method

 

  • oracle java 6 jre 32-bit

 $ wget http://download.oracle.com/otn-pub/java/jdk/6u34-b04/jre-6u34-linux-i586.bin
 $ chmod u+x jre-6u34-linux-i586.bin
 $ ./jre-6u34-linux-i586.bin
 $ sudo mkdir -p /usr/lib/jvm
 $ sudo mv jre1.6.0_34 /usr/lib/jvm/
 $ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_34/bin/java" 1
 $ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jre1.6.0_34/lib/i386/libnpjp2.so" 1
 $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_34/bin/javaws" 1

 

or

  • oracle java 6 jdk 64-bit

 $ wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin
 $ chmod u+x jdk-6u45-linux-x64.bin
 $ ./jdk-6u45-linux-x64.bin
 $ sudo mv jdk1.6.0_45 /opt
 $ sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_45/bin/java" 1
 $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk1.6.0_45/bin/javac" 1
 $ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/opt/jdk1.6.0_45/jre/lib/amd64/libnpjp2.so" 1
 $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/jdk1.6.0_45/bin/javaws" 1

 

  • IMPORTANT choose the java you installed as default

 $ sudo update-alternatives --config java
 $ sudo update-alternatives --config javac

 

Optionally you can set a JAVA_HOME env variable:

export _JAVA_HOME=/opt/jdk1.6.0_45/

 

Choosing the default Java to use

 

If your system has more than one version of Java, configure which one your system uses by entering the following command in a terminal window

sudo update-alternatives --config java

 

This will present you with a selection that looks similar to the following (the details may differ for you):

There are 2 choices for the alternative java (providing /usr/bin/java).  
Selection Path Priority Status 
———————————————————— 
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 
1 /usr/lib/jvm/jre1.7.0/jre/bin/java 3 manual mode  

Press enter to keep the current choice[*], or type selection number: 1
 
------------------------------------------------------------------------------------------------------------------------
 
 
  • Make the bin file executeable:
chmod +x jdk-6u32-linux-x64.bin
  • Extract the bin file:
./jdk-6u32-linux-x64.bin
  • For Ubuntu 13.04: There is no longer a jvm folder in /usr/lib, therefore create jvm folder
sudo mkdir /usr/lib/jvm
  • Move extracted folder to this location:
sudo mv jdk1.6.0_38 /usr/lib/jvm/jdk1.6.0_38
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_38/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_38/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_38/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_38/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_38/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Installing Sun JDK 7 on Ubuntu 12.04 / 12.10 / 13.04:

  • Download the sun jdk 7 tar file from here
  • Extract the tar file:
tar -xvzf jdk-7u11-linux-x64.tar.gz
  • For Ubuntu 13.04: There is no longer a jvm folder in /usr/lib, therefore create jvm folder
sudo mkdir /usr/lib/jvm
  • Move extracted folder to this location:
sudo mv jdk1.7.0_11 /usr/lib/jvm/jdk1.7.0_11
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_11/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_11/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_11/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Update: I have added Java Web Start configuration (Thanks Jack).

Update: I have added Java Plugin configuration for Mozilla Firefox even for Chrome (Thanks shetty).

Update: JAVA_HOME configuration: Some tools require JAVA_HOME variable. You can set JAVA_HOME in Ubuntu so simple: Edit the file .bashrc under your home directory and add the following lines: (if .bashrc is hidden, click in Nautilus Menu View > Show Hidden Files)

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_11 or /usr/lib/jvm/jdk1.6.0_38
export PATH=$JAVA_HOME/bin:$PATH

or add this JAVA_HOME=/usr/lib/jvm/jdk1.7.0_11 in /etc/environment with sudo gedit /etc/environment

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值