JAVA Installation in Linux

Fedora 8 comes with java icedtea which uses the source code from the OpenJDK project. It is very easy to install it through yum and it works just fine. Try it! If you still want to install the Sun Java go a few lines below.
OpenJDK
To install the java Plugin for Firefox type:

$ sudo yum install java-*-icedtea-plugin
Restart firefox and type about:plugins in the address bar. If the plugin has been successfully installed you should see ‘GCJ Web Browser Plugin’ among the plugins.

If you also want to use javac and java commands for compiling and running java programs type:

$ sudo yum install java-*-icedtea java-*-icedtea-devel
Sun Java
First you must install some libraries needed by Sun’ Java. Open a console and type:

$ sudo yum install compat-libstdc++-33 compat-libstdc++-296

When the libraries are installed create the neccessary links by typing:

$ sudo /sbin/ldconfig
Now click here to go to sun’s java site. You must download the Linux (self-extracting file) not the RPM file.

**Note: The rest of the guide is based on the i586 package. If you have Fedora x86_64 installed you should download the Linux x64 file and replace the file names as neccessary.

**Note: If you also want to compile java programs using Sun’s Java Development Kit Installation you must download Sun’s JDK bin file from here . Go to JDK 6 Update 3, accept the agreement and download the Linux self-extracting file (not the RPM file). The procedure is the same as below. You only have to replace jre1 with jdk1 in the following commands.

Go to the folder you have downloaded jre. Here it will be directory Desktop, Firefox’s default downlad directory.

$ cd ~/Desktop/
And type the following to install (when writting this guide 6u3 was the latest version, replace it with the file you have downloaded if it has changed):

$ sudo mv jre-6u3-linux-i586.bin /opt
$ cd /opt/
$ sudo chmod a+x jre-6u3-linux-i586.bin
$ sudo ./jre-6u3-linux-i586.bin
Use spacebar to read the agreement. At the end type yes to proceed with the installation.

Finally to make Firefox use the installed plugin type:

$ sudo ln -s ./jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so
$ sudo ln -s /opt/jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/firefox-2.0.0.8/plugins/libjavaplugin_oji.so
Restart firefox and type about:plugins in the address bar. If the plugins have successfully installed you should see Java(TM) Plug-in among the plugins.

Now, if you also want to run java programs using Sun’s java type in a console:

$ su –
(Give your root password)
# nano /etc/profile.d/java.sh
In that file copy the following:

export JAVA_HOME=/opt/jre1.6.0_03
export PATH=$JAVA_HOME/bin:$PATH
Next type:

# source /etc/profile.d/java.sh
# /usr/sbin/alternatives –config java
Here you should see something like this:

There are 2 programs which provide ‘java’.
Selection Command
———————————————–
*+ 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
Enter to keep the current selection[+], or type selection number:
Check how many programs provide java and press Ctrl+C. Here I have 2 so in the next command I will use 3 at the end of the command. Increase by one the number of programs that you have.

# /usr/sbin/alternatives –install /usr/bin/java java /opt/jre1.6.0_03/bin/java 3
# /usr/sbin/alternatives –config java
Now you should get something like this:

There are 3 programs which provide ‘java’.
Selection Command
———————————————– *+ 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
3 /opt/jre1.6.0_03/bin/java
Enter to keep the current selection[+], or type selection number:
Select the option you have entered e.g. 3. To test that you have correctly installed java type:

$ java -version
You should get something like that:

java version “1.6.0_03”
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
If at some time you update your Java installation simply remove the old one by typing:

$ sudo alternatives –remove java /opt/jre1.6.0_02/bin/java**Note: Currently there is a bug with Sun Java because it is incompatible with the newer libX11 included in Fedora 8. If you get an error like this xcb_xlib.c:50: xcb_xlib_unlock: Assertion ‘c->xlib.lock’ failed here is the workaround:

For sun-java5-bin:

sed -i ‘s/XINERAMA/FAKEEXTN/g’ /usr/lib/jvm/java-1.5.0-sun-1.5.0.11/jre/lib/i386/xawt/libmawt.soFor sun-java6-bin:

sed -i ‘s/XINERAMA/FAKEEXTN/g’ /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/i386/xawt/libmawt.soThe same fix (applied to the appropriate file) might work for other proprietary JDKs.

Advertisements

About Tanveer
RIA (Rich Internet Application) Developer with a wide variety of business applications. Particularly interested in client/server and relational database design. Always interested in migration projects, as well as close interaction with the DB manufacturers.

2 Responses to JAVA Installation in Linux

  1. My partner and I stumbled over here different web page
    and thought I may as well check things out. I like what I see so i am just following you.
    Look forward to checking out your web page repeatedly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: