This is the safest method of installing the Sun Java Development Kit (JDK) which can be used to for compiling programs in Java. If you have the JDK installed, you do not need to install the Java Runtime Environment (JRE) since it is already included in the JDK.
Applicable to Fedora Versions
- Fedora Core 5+
Requirements
- Fedora Core x86 Installation
- Mozilla x86 Installed or Firefox x86 Installed
- compat-libstdc++-33 These compatability libraries are requried with java 1.6+
- compat-libstdc++-296 These compatibility libraries are requried with java 1.6+
- Open a terminal .
-
Login as root by entering the following.
su --login
- At the password prompt enter the password for root.
- Install the compatiablility libraries by performing the following:
yum -y install compat-libstdc++-33 compat-libstdc++-296
- After the libraries are installed perform the following:
/sbin/ldconfig
- Ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib). The cache is used by the run-time linker, ld.so or ld-linux.so. ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their linksupdated.
- Once these steps are completed perform the steps listed in the Doing the Work Section
Doing the work
-
Download JDK 6 Update 3 bin here. (http://java.sun.com/javase/downloads/index.jsp ).
-
Select the download button next to “JDK 6 Update 3“
-
Select the circle for Accept License Agreement
-
Download the Linux [x64] Platform – Java(TM) SE Development Kit 6 Update 3 Self Extracting File
Example: jdk-6u3-linux-i586.bin or jdk-6u3-linux-amd64.binMake sure you download the correct file for your arch, either 32bit or 64bit. The rest of the howto uses the i586 version. Replace the filename as needed.Please note, the 64bit version plug-in will not work with the 32bit version of Firefox.
- Open a terminal .
-
Login as root by entering the following:
su --login
-
Now change to the directory /opt:
cd /opt
-
Execute the binary installation for JDK in the /opt directory:
(ensure that you use the path to the downloaded file i.e. /home/marc/downloads).
sh /home/marc/downloads/jdk-6u3-linux-i586.bin
After executing this command you will need to read through the License Agreement and type yes for the installer to actually start installing the software. Once installed it will create a folder “jdk1.6.0_03” in the /opt directory.
-
Now, to install the plug-in, execute the following command:
ln -sf /opt/jdk1.6.0_03/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so
-
Create a java.sh script by entering the following, ensure you press enter after each line of text entered:
cat <<EOF> /etc/profile.d/java.sh
export JAVA_HOME=/opt/jdk1.6.0_03
export PATH=\$JAVA_HOME/bin:\$PATH
EOF -
Run the following command:
NOTE: THIS STEP MUST BE EXECUTED AS ROOT, SEE STEP 6. IF EXECUTED VIA SUDO IT WILL CORRUPT YOUR PATH STATEMENT.source /etc/profile.d/java.sh
-
Add the alternative by running the following command:
/usr/sbin/alternatives --install /usr/bin/java java /opt/jdk1.6.0_03/bin/java 2
-
Configure the new alternative by running the following command.:
/usr/sbin/alternatives --config java
You should see something similar to the following:
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
2 /opt/jdk1.5.0_09/bin/java
3 /opt/jdk1.6.0_03/bin/java
Enter to keep the current selection[+], or type selection number:Select the number that is /opt/jdk1.6.0_03/bin/java. In this example the selection would be 3.
-
Double check that the correct java is selected:
/usr/sbin/alternatives --display java
You will see something like the following:
java - status is manual.
link currently points to /opt/jdk1.6.0_03/bin/java
/usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1420
slave keytool: /usr/lib/jvm/jre-1.4.2-gcj/bin/keytool
slave rmiregistry: /usr/lib/jvm/jre-1.4.2-gcj/bin/rmiregistry
slave jre_exports: /usr/lib/jvm-exports/jre-1.4.2-gcj
slave jre: /usr/lib/jvm/jre-1.4.2-gcj
/opt/jre1.5.0_09/bin/java - priority 2
slave keytool: (null)
slave rmiregistry: (null)
slave jre_exports: (null)
slave jre: (null)
/opt/jdk1.6.0_03/bin/java - priority 2
slave keytool: (null)
slave rmiregistry: (null)
slave jre_exports: (null)
slave jre: (null)
Current `best' version is /usr/lib/jvm/jre-1.4.2-gcj/bin/java. -
Close all instances of Firefox and the plug-in should be functioning properly now. You should now be able to install and run Java applications and use Firefox to view embedded java applets.
Troubleshooting
How to test
If everything went well you should see a gray box with a little dancing java logo and above the logo should be your java information.
Common problems and fixes
If java applications do not run after restarting Firefox, you may need to check your /var/log/audit/audit.log or /var/log/messages for audit messages. If you see messages similar to the following “type=AVC msg=audit(1144977424.506:73): avc: denied { execmod } for pid=3005 comm=”java_vm” name=”libdeploy.so” dev=dm-0 ino=3274482 scontext=user_u:system_r:unconfined_t:s0 tcontext=system_u:object_r:lib_t:s0 tclass=file” you may need to fix the SELinux context by doing the following as root:
chcon -t textrel_shlib_t /opt/jdk1.6.0_03/jre/lib/i386/libdeploy.so
Removing An Old Alternative for Java
For example, if you have installed jre1.6.0_01 and want to remove jdk 1.6.0, do the following:
alternatives --remove java /opt/jdk1.6.0/bin/java
xcb_xlib.c:50: xcb_xlib_unlock: Assertion ‘c->xlib.lock’ failed.
If you get the error shown above it means that you need to patch Java. This happens in Fedora 8.
su -c '/bin/sed -i 's/XINERAMA/FAKEEXTN/g' /opt/jdk1.6.0_03/jre/lib/i386/xawt/libmawt.so'
Leave A Comment