Gentoo中安装配置Oracle JDK

在Gentoo中如果直接emerge jdk,会安装virtual/jdk这个包,默认依赖开源的dev-java/icedtea-bin;

如果直接emerge oracle-jdk-bin,则直接安装高版本的oracle-jdk-bin-1.8,同时也会安装icedtea-bin。

想直接用oracle-jdk-bin-1.7的话,不想安装icedtea-bin,并且不用mask掉高版本的oracle-jdk,可以这样来安装:

1、查找1.7的oracle-jdk具体版本

ls /usr/portage/dev-java/oracle-jdk-bin/

结果如下:

ChangeLog  files         oracle-jdk-bin-1.7.0.60.ebuild  oracle-jdk-bin-1.7.0.72.ebuild
Manifest   metadata.xml  oracle-jdk-bin-1.7.0.71.ebuild  oracle-jdk-bin-1.8.0.25.ebuild

确定1.7的版本号为oracle-jdk-bin-1.7.0.72。

2、安装此版本的oracle-jdk

emerge -av =oracle-jdk-bin-1.7.0.72

出现如下提示:

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   RF   ] dev-java/oracle-jdk-bin-1.7.0.72:1.7  USE="X alsa fontconfig (-aqua) -derby -doc -examples -jce -nsplugin -pax_kernel (-selinux) -source" 138,893 KiB

Total: 1 package (1 reinstall), Size of downloads: 138,893 KiB
Fetch Restriction: 1 package (1 unsatisfied)

Fetch instructions for dev-java/oracle-jdk-bin-1.7.0.72:
 * 
 * Oracle requires you to download the needed files manually after
 * accepting their license through a javascript capable web browser.
 * 
 * Download the following files:
 *   jdk-7u72-linux-x64.tar.gz
 * at 'http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html'
 * and move them to '/usr/portage/distfiles'
 * 
 * If the above mentioned urls do not point to the correct version anymore,
 * please download the files from Oracle's java download archive:
 * 
 *    http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u72-oth-JPR
 * 

Would you like to merge these packages? [Yes/No]

说明需要去oracle官网去下载“jdk-7u72-linux-x64.tar.gz”,去下面提示的“http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html”下载。前提是你要有oracle的帐号,登录之后,同意下载协议后就可以下载。下载之后,将文件复制到/usr/portage/distfiles/目录才可以安装。

3、最后再安装virtual/jdk

emerge -av jdk

你会发现不再安装icedtea-bin这个包了。

4、配置jdk

eselect java-vm list

出现:

Available Java Virtual Machines:
[1]   icedtea-bin-1.7  system-vm //注:好像是这样,记不清了,因为设置之后就没这个选项了

[2]   oracle-jdk-bin-1.7

然后运行:

eselect java-vm set system 2

设置完成,查看一下:

eselect java-vm list

出现如下提示,说明设置正确了。

Available Java Virtual Machines:
[1]   oracle-jdk-bin-1.7  system-vm

 

5、设置JAVA_HOME、JDK_HOME

vi /etc/profile

将下面两行添加到文件末尾:

JAVA_HOME=/opt/oracle-jdk-bin-1.7.0.72
JDK_HOME=/opt/oracle-jdk-bin-1.7.0.72/bin

至此,整个安装配置过程完成。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据