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).
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)
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.
- ▼ March (5)
- ► 2007 (29)