Thursday, October 27, 2011

First Post

Installing Java on Fedora

Java is not usually included in Linux. OpenJDK is great but sorry to say it doesn't seem to work on my net-banking website. I have complained but till the situation betters I have to use the JDK supplied by Sun. Which is a closed source option.
Installing Java on Linux is a bit different than on Windows. There is point and click option available on most of the newer Linux flavours for the OpenJDK. But for the Sun Java only commandline option is there. The command-line option is a quick way to do it cleanly. I have tried this on Fedora, Ubuntu. It should work on most.

1. Download latest Java
Go to the Sun java website to download latest java binary.
http://www.java.com/en/download/linux_manual.jsp?locale=en
Current version is Java 6 Update 29.



2. Install Java
First make the downloaded file to executable.

$ chmod u+x jre-6u29-linux-i586.bin

Go root and make a folder /usr/java

$ su
# mkdir /usr/java

Copy the executable to the above made directory. Run the executable.

# cp /<Download Directory>/jre-6u29-linux-i586.bin /usr/java
# ./jre-6u29-linux-i586.bin 

3.Configuring the computer

This will create extract the required files and install the files in the folder /usr/java/jre1.6.0_29. The executable for java is present in the folder /usr/java/jre1.6.0_29/bin. It is possible to install multiple versions of java in your computer at the same time and use it as needed. It is possible with the help of alternatives command.

# alternatives --install /usr/bin/java java /usr/java/jre1.6.0_29/bin/java 120 --slave /usr/bin/keytool keytool /usr/java/jre1.6.0_29/bin/keytool --slave /usr/bin/rmiregistry rmiregistry /usr/java/jre1.6.0_29/bin/rmiregistr

# alternatives --config java

There are 4 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/java/jre1.6.0_27/bin/java
*  2           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   3           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 4           /usr/java/jre1.6.0_29/bin/java

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

* shows the most appropriate choice, i.e. Open source Java ;-). Now you will have multiple Java installed and choice can be changed by alternatives --config java command. Most recently installed Java will be the lowest one and select it.


Installing Firefox Java plugin

This install also provides the latest java plugin for your favourite browser Firefox. Older plugin was named libjavaplugin.so or libjavaplugin_oji.so. The newer plugin is libnpjp2.so. Similar to the multiple versions of Java present in your computer you can have multiple versions of plugin installed and use whichever is appropriate for you. You install the plugin in a similar way with alternatives command.

alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jre1.6.0_29/lib/i386/libnpjp2.so 1
 
alternatives --config libjavaplugin.so
 

I hope this first post of mine helps you. Any comments will be helpful. If there is an easier way please add in the comments I will surely add it.

You can test the installation by visiting http://www.java.com/en/download/testjava.jsp 


In RPM based distros such as Fedora installation is simpler as the file jre-6u29-linux-i586-rpm.bin extracts RPM and installs the java at the above mentioned place /usr/java. Rest of the commands for configuring by alternatives remain the same.

These directions is for 32 bit Linux. I haven't tried 64 bit Linux as yet since I dont have a 64 bit computer, so any directions for that will be welcome. Or I will post it as soon as I get my hands on such a computer.

3 comments:

  1. Please don't recommend solutions that will break a number of Java applications shipped with Fedora. There is a lot more to be done than simply symlinking java and javaplugin! Can you verify that the system jar executable is not broken by your java symlink? Or javadoc or javac or javadoc or javah or `name on of the zilion jdk tools`?
    This may work for your banking software but I'm tired of trying to understand bugreports from people that have followed some random site.
    If you want to see things improve please work with us (Fedora community) to improve things not giving guidelines howto break someone else's system.
    Btw, is there a bugreport for your problem?

    ReplyDelete
  2. Alexander obviously knows much more about the stuff than I do, but the question I had was whether it would be possible to report what exactly is broken in the banking site to a) the site itself, b) OpenJDK maintainers?

    ReplyDelete
  3. Thanks Alexander for your comments. This post was not intended for breaking any persons system. This was just a way to make sense of the instructions given on the Sun Java website. I have already specified that this is a way to use multiple versions of java on your computer. I have nothing against OpenJDK i would have used it but for this trouble.

    ReplyDelete