Java On Ubuntu

Debian-derived systems including the Ubuntu family package GCJ as their default Java provider. To install Sun Java, follow these steps:

  1. Make sure the Multiverse repository is enabled in /etc/apt/sources.list.
  2. Install the following packages:
    • Java 6: sudo apt-get install sun-java6-jdk sun-java6-jre
    • Java 5: sudo apt-get install sun-java5-jdk sun-java5-jre
    You do not need to uninstall GCJ first.
  3. Tell the system to use the Sun Java installation:
    • Java 6: sudo update-java-alternatives --set java-6-sun
    • Java 5: sudo update-java-alternatives --set java-1.5.0-sun

To verify that this worked, use java -version. You should see something like this:

  Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
  Java HotSpot(TM) Server VM (build 1.5.0_11-b03, mixed mode)

Likewise, check javac -version. You should see something like this:

  javac 1.5.0_11
  javac: no source files
  Usage: javac <options> <source files>
  where possible options include:
     ...

See Also