1.安装JDK
1.1安装open jdk
$ sudo apt-get update $ sudo apt-get install openjdk-8-jdk
1.2配置默认jdk
分别执行下面四个命令,选择openjdk
那一项为默认项
$ sudo update-alternatives --config java $ sudo update-alternatives --config javac $ sudo update-alternatives --config jar $ sudo update-alternatives --config javadoc
1.3设置环境变量
输入如下命令打开profile文件
$ sudo gedit /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH={JAVA_HOME}/bin:$PATH
然后执行如下命令更新配置
$ source /etc/profile
输入$ echo $JAVA_HOME
,如果输出为openjdk字样表示配置正确
1.4切换jdk
如果切换jdk(例如编译Android M需要open jdk1.7),
1.执行1.2的命令,设置默认jdk
2.更改环境变量/etc/environment
,更改配置/etc/profile
(见1.3)
$ sudo gedit /etc/environment
添加:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 export JRE_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH={JAVA_HOME}/bin:$PATH
更新设置:
$ source /etc/environment
2.安装相关依赖库
16.04的依赖与14.04有些许不同,官方教程
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386 sudo apt-get install tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 sudo apt-get install dpkg-dev libsdl1.2-dev libesd0-dev sudo apt-get install git-core gnupg flex bison gperf build-essential sudo apt-get install zip curl zlib1g-dev gcc-multilib g++-multilib sudo apt-get install libc6-dev-i386 sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip m4 sudo apt-get install lib32z-dev ccache原文链接:https://www.f2er.com/ubuntu/353876.html