Skip to main content

Howto Setup Sun Java on Linux Manually

I'm not switching to Java. :) But this particular thing is something I've answered several times. So instead of repeating it every time, I'll put the details here and point others here. Installing Sun's Java (JDK and JRE) manually, without using something like yum, apr-get, urpm, etc. seems to be something many desktop (or whatever) Linux users want. For example they want to run certain applications like NetBeans, FrostWire, etc. which require a JRE to be available. This tutorial is going to take you through the steps you need to setup a working JRE/JDK on a Linux system. You may as well take this idea and tune it for your non-Linux environments like Solaris, *BSD.

Note: This howto assumes you have 'sudo' configured for you. If you don't have 'sudo' configured, you'll have to either use 'su' or login as root to use the commands I have provided with 'sudo' at the beginning. Please replace file names and paths in this howto with your own values.

1. First download the JRE/JDK from Sun ( For the rest of the tutorial I'll use JRE 6 Update 2, but even if you want to setup JDK it's still the same steps. The selection of the package is your choice. Remember, the .bin (not -rpm.bin) file can be used on virtually any Linux distribution, given they have fairly up to date components and correct architecture (Eg: x86, x86_64, etc.).

You can get the JRE as a Linux self extracting file (.bin) or a RPM archive (-rpm.bin) file at the moment. Even if they change these things, I think they'll still provide the archive (not the package).
Eg: jre-6u2-linux-i586.bin

2. After you complete your download, go to the directory you have it on disk.
Eg: $ cd ~/skyeye/Desktop/ if you have it on your desktop

3. Change the permissions so that you can execute the file
Eg: $ chmod a+x ./jre-6u2-linux-i586.bin

4. Execute it
Eg: $ ./jre-6u2-linux-i586.bin

5. You'll have to go through the Sun's license notice and accept it to use the JRE/JDK. After this the package will extract and you will have a directory
Eg: ./jre1.6.0_02 if/ you downloaded the .bin file, or you'll have a jre1.6.0_02-i586.rpm file if you downloaded the -rpm.bin file.

6. If you now have a .rpm file, you only have use rpm (Eg: rpm -U) or a relevant utility (Eg: yum localinstall)
Eg: $ sudo rpm -Uvh jre1.6.0_02-i586.rpm

You are done. Contgratz!

But if you downloaded the .bin in the first place, please proceed from step 7.

7. Move your new JRE/JDK directory where people can access
Eg: $ sudo mv ./jre1.6.0_02 /opt/

8. Add the path to the bin directory within your JRE/JDK directory, to your systems $PATH. Use your preferred editor to edit the relevant configuration file to set the PATH persistently. If you are going to add it to the system wide PATH so that anyone can get it, edit /etc/profile. If you just want it for you, edit your .bashrc (~/.bashrc). As you may have guessed this is for the setups using GNU Bash. If you use a different shell, the lines in step 9 might need to be changed. Luckily almost all mainstream Linux distributions use Bash as the default shell.
Eg: $ sudo vi /etc/profile

9. Add the following lines after everything (replace /opt/jre1.6.0_02/bin with your JRE bin path)

export PATH

save (write to) the file and exit. Now, next time you log in, you'll have a Sun JRE ready for you. What step 9 exactly does is, add the path of the Java bin directory to the system PATH variable at the beginning.

That's all. See, not that difficult. But of course, if you are using modern distributions like Ubuntu, Fedora, Debian, etc. you don't have to go through all these. Sun Java packages are usually available through the repositories. Just use your favorite package management software (Eg: Synaptic, YumEx, apt-get, yum, etc.) to install it.


  1. Dam I feel I will be kicked out of industry if I really don't get some linux knowladge.. dam Microsoft is eating me.. Got to start now before I finish the degree.. Nice post bro..

  2. Thanks for the comment.

    And of course, learning a bit about Linux and other FOSS tools will be great for your career in web technologies.

    BTW, I strongly recommend you to use Linux. :)


Post a Comment

Popular posts from this blog

Howto Install Docky on Fedora

If you know me personally, then you know that I'm a big fan of GNOME Do. As a keyboard savvy person I use Do extensively. Do is an application launcher similar to the Mac app Quicksilver. However the GNOME Do team has been putting a lot of research and development into it from the initiation. Result: probably the best application launcher out there for any platform.
Some months ago, Do included an interesting theme called Docky which made the launcher acts as a dock (a la Mac, Avant, Cairo Dock, etc.). With the integration of GNOME Do, there's no need to say that Docky was super cool. And it started gaining features in a high speed. Ultimately Docky was getting so developed that it became a separate project.
Installing GNOME Do on a Fedora system is as easy as: $ sudo yum install gnome-do
There are some packages with the names starting from gnome-do-plugins*. With the addition of these GNOME Do can truly enhance your desktop experience. Give it a fair try, I'm pretty sure you&…

Howto Migrate from Thunderbird to Evolution

I know some of you are asking why, rather than how, regarding migration from Mozilla Thunderbird to Evolution. Maybe that's why there are lot of Evolution to Thunderbird migration guides, but not many vice-versa. Fear not, here is a guide, to assist who dare to migrate from Thunderbird to Evolution. The techniques described here are tested with the newer versions of both the software, namely Thunderbird and Evolution 2.10.2. On higher versions also this should work without an issue.

I think Mozilla people are doing a wonderful job with both Firefox and Thunderbird. From my point of view Firefox is the best general purpose web browser around. It beats most proprietary browser in speed, stability, security, modularity, etc. (and don't start commenting the so and so browsers are greater or so and so is cool too. I know they may be, Fx is simply my choice. This also applies to any comparisons with Evolution too :) However Fxs' counterpart in e mail business, is not yet …

Howto setup a MySQL Connector/J 5.1 for Tomcat on Linux

Again, I'm not switching to Java. :) For clarity, I'm helping one of my online buddies to setup and use Ruby even as I write this. This work was something I had to do for a Rails project which used JSPs and stuff with a MySQL database over JDBC. The application setup was quite interesting calling JSPs to work with a Rails webapp.

Actually the following things are found on the Internet. I cannot remember all the sources I looked at, but one was the MySQLs own documentation and Apache Tomcat documentations. So if this works (which in my case did), credit should not be mine. :)

Here's the setup.
GNU/Linux (in my case CentOS 5, although should work with any Linux distro)Apache Tomcat (5.5.25, should work with Tomcat 5.5 range)Sun JDK (1.6.0_04)MySQL (5.0.22)MySQL Connector/J (5.1)

1. I assume that Java is setup (See my previous post for more details on setting up Java manually), and your MySQL is running on the same host on port 3306. Please replace your actual settings if they ar…