Thursday, April 22, 2010

Install/Uninstall Java on Linux

These commands were tested on CentOS 5.3

Installing Java
  1. Download the latest stable JDK from here.
  2. RPM users (CentOS, RedHat, Fedora) should use the RPM builds.
  3. Non-RPM users (Debian, Ubuntu) should use the self extracting binary file.
  4. Remove the existing Java version.
  5. Install new Java version.

RPM Users

Install
  • The RPM file I am using is jdk-6u20-linux-x64-rpm.bin.
  • chmod +x jdk-6u20-linux-x64-rpm.bin
  • ./jdk-6u20-linux-x64-rpm.bin

Remove Java
  • In this example I am uninstalling jdk-6u16.
  • rpm -e sun-javadb-common-10.4.2-1.1 sun-javadb-client-10.4.2-1.1 sun-javadb-demo-10.4.2-1.1 sun-javadb-docs-10.4.2-1.1 jdk-1.6.0_16-fcs
  • This everything that was installed by the jdk-6u-linux-x64-rpm.bin package.

NON-RPM Users

Install
  • chmod +x jdk-6u20-linux-x64-bin
  • ./jdk-6u20-linux-x64-.bin
Remove Java
  • Find the installation directory. Assume it is installed in /usr/java/jdk1.6.0_16
  • Since this was a self extracting install all you have to do is remove the directory and its contents using the command shown below.
  • rm -rf /usr/java/jdk1.6.0_16
RPM and NON-RPM Users
Remember to remove the system or update the system variable JAVA_HOME. (The /etc/profile file for CentOS users).

Overview of JDK and JRE file structure here

No comments:

Post a Comment