-
安装 OpenJDK-7
在 Ubuntu 16.04 及以上版本中,按照以下方法安装可能会出错:sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-7-jdk
OpenJDK-7 package's description: Copied from debian experimental in Primary Archive for Debian GNU/Linux.
参考 https://askubuntu.com/questio...:
(1) 创建一个 pinning ( https://help.ubuntu.com/commu... ) 文件,让 Linux 管理工具 apt 只需考虑对我们有用的 package.
a) 编辑文件 (未测试成功的命令: sudo vim,gksudo gedit)sudo nano
b) 输入以下内容
Package: * Pin: release o=Debian,n=experimental Pin-Priority: -1 Package: * Pin: release o=Debian,n=sid Pin-Priority: -1 Package: openjdk-7-jdk Pin: release o=Debian,n=experimental Pin-Priority: 500 Package: openjdk-7-jre Pin: release o=Debian,n=experimental Pin-Priority: 500 Package: openjdk-7-jre-headless Pin: release o=Debian,n=experimental Pin-Priority: 500 Package: libjpeg62-turbo Pin: release o=Debian,n=sid Pin-Priority: 500 ## Ubuntu 17.10 及以前版本需要添加以下内容 Package: libfontconfig1 Pin: release o=Debian,n=sid Pin-Priority: 500 Package: fontconfig-config Pin: release o=Debian,n=sid Pin-Priority: 500
c) 保存文件
Ctrl + X -> 输入文件名 /etc/apt/preferences.d/debian
(2) 安装 Debian keyring
sudo apt install debian-archive-keyring
注意:这种添加 Debian keyring 的方法是最简单的,但它可能不是最新的。
W: GPG error: http://cdn-fastly.deb.debian.org/debian experimental InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010 E: The repository 'http://httpredir.debian.org/debian experimental InRelease' is not signed.
如果在步骤(4)出现以上错误信息,需要按以下方法手动添加缺少的 keys (NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010):
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
(3) 添加必要的 repository
sudo add-apt-repository 'deb http://httpredir.debian.org/debian experimental main' sudo add-apt-repository 'deb http://httpredir.debian.org/debian sid main'
Why not use a stable Debian repository? You'll run into unsatisfiable dependencies with Debian stable. The experimental (for openjdk-7) and sid (for libjpeg62-turbo,libfontconfig1,and fontconfig-config) repositories are more lenient with dependency versions.
(4) 更新 apt 缓存
sudo apt update
(5) 安装 openjdk-7-jdk
sudo apt install openjdk-7-jdk
(6) 更新 java 可选项
查看已安装的 java 版本 sudo update-java-alternatives --list 激活 OpenJDK-7 sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
-
配置环境变量
(1) 查看安装路径dpkg -L openjdk-7-jdk | grep '/bin/javac'
OpenJDK-7 安装成功后的目录位于 /usr/lib/jvm 下.
gedit /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
输入以下命令使配置生效:
source /etc/profile
(3) 验证 Java 能否工作
java -vesion
java version "1.7.0_161" OpenJDK Runtime Environment (IcedTea 2.6.12) (7u161-2.6.12-1) OpenJDK 64-Bit Server VM (build 24.161-b01,mixed mode)
(4) 配置默认JDK
ubuntu 下默认 JDK 是 openJDK,输入以下命令:sudo update-alternatives --install /usr/lib/java java /usr/lib/jvm/jdk1.7.0_17/bin/java 300 sudo update-alternatives --install /usr/lib/javac javac /usr/lib/jvm/jdk1.7.0_17/bin/javac 300
执行以下命令,会列出一系列 JDK 版本,其中标注有 * 的为默认 JDK:
sudo update-alternatives --config java
如果要维持当前默认JDK,直接按回车键即可;否则输入相应JDK的编号将其设置为默认版本。
-
安装 Apache-Ant
ubuntu16.04安装ant https://blog.csdn.net/dawn_02...