如何在Fedora 17 18 19 20 21 22 23 系统中安装 openjdk 1.6 与 1.7 1.8 共存

首先在高版本Fedora中,没有java-openjdk-1.6包,需要在网上下载,比如CentOS 7中的java-openjdk-1.6包:java-1.6.0-openjdk-1.6.0.36-1.13.8.1.el7_1.x86_64.rpm,实测可在Fedora 20中安装。

以下为转载,主要注意安装提示“java-1.7.0-openjdk obsoletes java-1.6.0-openjdk”时,使用rpm -nodeps就可以了,然后还需要:update-alternatives --config java和update-alternatives --config javac,指定1.6版本:

yum install java-1.6.0-openjdk --releasever=16 --nogpgcheck

(--nogpgcheck because yum complains of not having the key for Fedora 16, maybe there are better ways to solve this)

But this shows, that java-1.7.0-openjdk obsoletes java-1.6.0-openjdk and skips installation. And it shows that the packagexorg-x11-fonts-Type1 is needed. So I did

yum install xorg-x11-fonts-Type1

and then I used the openjdk package which yum downloaded but refused to install because of theobsoletes warning

rpm --nodeps -ihv /var/cache/yum/x86_64/16/updates/packages/java-1.6.0-openjdk-1.6.0.0-68.1.11.5.fc16.x86_64.rpm

(--nodeps for overriding the obsoletes warning)

Now I have both java 1.6 and java 1.7 on my system. Java 1.7 is my default. And Java 1.6 is in/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java.

PS: There won't be any conflicts when you install both 1.7 and 1.6. The reason for removing 1.6 from Fedora 17 was, that OpenJDK6 willno longer get security updates after November 2012.

PS: Please vote up, if you liked my answer.


#update-alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 2


# update-alternatives --config javac

There is 1 program that provides 'javac'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/bin/javac

Enter to keep the current selection[+], or type selection number:  

你可能感兴趣的:(如何在Fedora 17 18 19 20 21 22 23 系统中安装 openjdk 1.6 与 1.7 1.8 共存)