Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I compile to Java 6 on Fedora 17 using OpenJDK

I want to compile to Java 6 using OpenJDK on Fedora 17. Fedora 17 has OpenJDK7, not OpenJDK6. I am fine to target compile to Java 6 from Java 7 using -target 1.6 -source 1.6 but to do it right (avoid warning: [options] bootstrap class path not set in conjunction with -source 1.6), I also need -bootclasspath pointing to a Java 6 rt.jar file. But OpenJDK7 doesn't provide this Java 6 rt.jar file. How can I correctly compile for Java 6 on FC17?

like image 239
Bruce Avatar asked Dec 27 '22 19:12

Bruce


2 Answers

To install Openjdk 1.6 from Fedora 16 use this command:

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 package xorg-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 the obsoletes 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 will no longer get security updates after November 2012.

like image 160
erik Avatar answered Dec 29 '22 07:12

erik


You will need OpenJDK 6.

I went to OpenJDK's install instructions page, and they recommended using yum

However, I did verify that this was not a build of OpenJDK 1.6 available for Fedora 17 (I am running FC17 as well):

yum list java*-openjdk
Loaded plugins: langpacks, presto, refresh-packagekit
Available Packages
java-1.7.0-openjdk.i686    1:1.7.0.5-2.2.1.fc17.9       updates
java-1.7.0-openjdk.x86_64  1:1.7.0.5-2.2.1.fc17.9       updates

Here is the same question posted on superuser.com regarding Install older openjdk 1.6 on Fedora 17. The accepted answer was basically to download and install it manually.

If you just want to compile to Java 6, and are not absolutely set on using OpenJDK6, I could help you with step-by-step on doing so using Oracle's JDK 1.6.0_33. That is the JDK that I use on Fedora 17.

like image 21
Philip Tenn Avatar answered Dec 29 '22 08:12

Philip Tenn