From Notes Wiki
Installing Java on Ubuntu 12.04 x86 64 Desktop
To install Java on Ubuntu 12.04 x86_64 Desktop use following steps:
- Download java-sdk with netbeans from http://www.oracle.com/technetwork/java/javase/downloads/index.html Download .sh file.
- Give execute permissions to .sh file using 'chmod +x jdk-7u40-nb-7_3_1-linux-x64.sh'. In this and all future steps replace the version of java and netbeans with the version of java and netbeans downloaded appropriately.
- Execute setup using 'sudo jdk-7u40-nb-7_3_1-linux-x64.sh' or similar command based on version downloaded.
- Choose to install both jdk and netbeans in '/opt/jdk1.7.0_40' and '/opt/netbeans-7.3.1' etc. instead of installing in '/usr/local'. Again name of folders inside opt may differ based on java and netbeans versions.
- Check for currently installed java versions using 'java' command. If some other java is already installed, uninstall it using package managers.
- Edit file '/etc/bash.bashrc' and append following lines at the end:
- Open a new terminal and verify that oracle java installed in /opt has highest priority using 'which java'.