I recently re-installed my desktop and switched from Debian to Ubuntu (personal choice for my own reasons). Doing a fair amount of Python lately, I have gotten to really like using the Community Edition of
Pycharm.
Unfortunately, while Pycharm is pretty sweet, its also written in Java (not a favorite of mine). So, with that tidbit of info, I will now go through the steps necessary to install and setup Java on Ubuntu 12.04.
The first thing your going to need to do is
download the JDK from Oracle. After you download it, you will need to unpack it (below I used the name of the version I downloaded):
tar -zxvf jdk-7u45-linux-x64.tar.gz
After you unpack the tarball, you will have a directory with the software in it (mine was named jdk1.7.0_45). You will want to move the new directory to a usable location. I moved mine to the /usr directory as such:
sudo mv ./jdk1.7.0_45 /usr/
You will need to make sure to do this as sudo, as root owns /usr/.
Next, you are going to want to set the JAVA_HOME variable, which is done in either your .profile or your .bashrc in your home directory:
export JAVA_HOME=/usr/jdk1.7.0_45
Just for giggles, I added a path to the bin directory where the java executables are located. To do this I simply edited my .profile and added "/usr/jdk1.7.0_45/bin" to the PATH variable.
You now have to execute the following:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/jdk1.7.0_45/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/jdk1.7.0_45/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/jdk1.7.0_45/bin/javaws" 1
Now, create a plugins directory for Mozilla:
mkdir ~/.mozilla/plugins/
And create a link to the necessary file:
ln -s /usr/jdk1.7.0_45/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
After that, your JDK is now installed. Just a bit of informaiton. Some people have said that you don't need the "update-alternatives" lines in order to complete this, just the path addition. Actually, for me, it did not work until I did those links.
Enjoy and hope it works for you too.