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 (http://java.sun.com/javase/downloads/) 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)

PATH=/opt/jre1.6.0_02/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.

Comments

  1. Anonymous6:33 PM

    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..

    ReplyDelete
  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. :)

    ReplyDelete

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

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 2.0.0.4 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 y

Howto Setup a Subversion (svn) Repository for a Rails Project + Bonus

Setting up a Subversion (svn) repository is something development teams have to do fairly regularly, not that I want to use Subversion. :) If you listen to me, go use Git . Subversion is undoubtedly very good. But after using Git for about a year, you can't simply get me to switch back. Git is that good. :) I've written about Git before . In cases where you can't use Git (or you feel too castrated by TortoiseSVN, pardon me for the pun) you can use Subversion. In this post I'll go through the steps you have to follow to get a basic Subversion setup up and running on a CentOS 5 Linux host. However I think you should be able to use this on other Linux distros too. There's more than one way to host a Subversion repo. I'm going to stick with one way involving WebDAV. Don't mind the buzz word. It's the most common usage for this purpose. If you want a repository where you want to checkout and commit remotely, this is an easy way of getting it done. In addition