Debian GNU/Linux and Ubuntu
Install Sun Java JDK, JRE and plugin
Sun Java and Oracle Java have been removed from Ubuntu official repositories.
Use oab-java.sh script from GitHub to build Debian/Ubuntu .deb packages and set up a local repository, install from there, this is high recommended.
Set the default JDK at system level
If you want to choose which JDK to use for apps installed via Debian deb package, set the default JVM in /etc/jvm.
For example, in Ubuntu Intrepid Ibex 8.10:
Of course the traditional way still works. Edit ~/.bash_profile, ~/.bashrc or /etc/profile.
Login / Non-interactive Shell & Login / Interactive Shell
Bash executes the following files in order
- /etc/profile [^sysconfdir]
Non-login / Interactive Shell (for example gnome-terminal)
Bash executes the following in order
Global bashrc (defined as SYS_BASHRC when compiling, by default it is /etc/bash.bashrc)
Bash startup files
Red Hat Enterprise Linux, Oracle Enterprise Linux and CentOS
Use the rpm.bin download from Sun, it's a binary file which extracts the rpm packages.
By default, JDK 1.6.0_16 will be installed under /usr/java /jdk1.6.0_16. There are 2 soft links under /usr/java, latest and defaut, which makes it easier to set up the environment variable.
Use the path below to avoid changing the JDK path every time you upgrade JDK.
Traditional way of setting Java environment variables
Single user's .bash_profile or .bashrc which is loaded whenever a Terminal is opened.
Add the snippet:
Or write it in a script file like setenv.sh, chmod u+x setenv.sh and then source it.
Test using java -version
2. system wide profile, /etc/profile
Save, log out and login again to see if it works. It it doesn't, try source /etc/profile.
3 write a script, script under /etc/profile.d will be loaded when starting up.