Installing Sun JDK

Preamble

This page contains instructions for installing the Sun Java Development Kit (JDK) for Windows and Linux/UNIX.

Please refer to our [Supported Platforms] topic for details on the Sun JDK versions which are supported for Confluence.

Mac OS X users can ignore these instructions because this operating system already comes pre-installed with a JDK.

Linux Installation

Distribution-Specific Installation Guide

The installation guide below is generic. For more detailed information or easier procedures for installing Java on your Linux platform, you can refer to the following table :

Generic Installation Guide of the Sun JDK on Linux

  1. Create the JDK installation directory :
    # mkdir /usr/java
    
  2. Copy the JDK binary in this directory :
    # cp  jdk-6u18-linux-x64.bin /usr/java
    
  3. Move into the JDK installation directory :
    # cd /usr/java
    

    By default, the downloaded binary can't be executed. You must give it the executions rights :

    # chmod a+x  jdk-6u18-linux-x64.bin
    
  4. Launch the installer :
    # ./jdk-6u18-linux-x64.bin
    


    (Press the space bar many times to go to the end of the licence contract and type yes then press the enter key).

  5. Remove all the installation binaries :
    # rm -f *.rpm *.bin
    
  6. You then need to create 2 more directories (if they are not automatically created) :
    # ln -sf /usr/java/jdk1.6.0_18/ /usr/java/current
    # ln -sf /usr/java/jdk1.6.0_18/ /usr/java/latest
    
    You must now have three directories :
    • default : a symbolic link on the JDK version run by default
    • jdk1.6.0_18 : the version of the JDK we've just installed
    • latest : a symbolic link on the latest JDK version available on the machine
  7. You must now declare the alternatives for some executables as java, javac, ...
    alternatives --install /usr/bin/appletviewer appletviewer /usr/java/default/bin/appletviewer 2000
    alternatives --install /usr/bin/apt apt /usr/java/default/bin/apt 2000
    alternatives --install /usr/bin/extcheck extcheck /usr/java/default/bin/extcheck 2000
    alternatives --install /usr/bin/idlj idlj /usr/java/default/bin/idlj 2000
    alternatives --install /usr/bin/jar jar /usr/java/default/bin/jar 2000
    alternatives --install /usr/bin/jarsigner jarsigner /usr/java/default/bin/jarsigner 2000
    alternatives --install /usr/bin/java java /usr/java/default/bin/java 2000
    alternatives --install /usr/bin/javac javac /usr/java/default/bin/javac 2000
    alternatives --install /usr/bin/javadoc javadoc /usr/java/default/bin/javadoc 2000
    alternatives --install /usr/bin/javah javah /usr/java/default/bin/javah 2000
    alternatives --install /usr/bin/javap javap /usr/java/default/bin/javap 2000
    alternatives --install /usr/bin/javaws javaws /usr/java/default/bin/javaws 2000
    alternatives --install /usr/bin/jconsole jconsole /usr/java/default/bin/jconsole 2000
    alternatives --install /usr/bin/jcontrol jcontrol /usr/java/default/bin/jcontrol 2000
    alternatives --install /usr/bin/jdb jdb /usr/java/default/bin/jdb 2000
    alternatives --install /usr/bin/jhat jhat /usr/java/default/bin/jhat 2000
    alternatives --install /usr/bin/jinfo jinfo /usr/java/default/bin/jinfo 2000
    alternatives --install /usr/bin/jmap jmap /usr/java/default/bin/jmap 2000
    alternatives --install /usr/bin/jps jps /usr/java/default/bin/jps 2000
    alternatives --install /usr/bin/jrunscript jrunscript /usr/java/default/bin/jrunscript 2000
    alternatives --install /usr/bin/jsadebug jsadebug /usr/java/default/bin/jsadebug 2000
    alternatives --install /usr/bin/jstack jstack /usr/java/default/bin/jstack 2000
    alternatives --install /usr/bin/jstat jstat /usr/java/default/bin/jstat 2000
    alternatives --install /usr/bin/jvisualvm jvisualvm /usr/java/default/bin/jvisualvm 2000
    alternatives --install /usr/bin/keytool keytool /usr/java/default/bin/keytool 2000
    alternatives --install /usr/bin/native2ascii native2ascii /usr/java/default/bin/native2ascii 2000
    alternatives --install /usr/bin/orbd orbd /usr/java/default/bin/orbd 2000
    alternatives --install /usr/bin/pack200 pack200 /usr/java/default/bin/pack200 2000
    alternatives --install /usr/bin/policytool policytool /usr/java/default/bin/policytool 2000
    alternatives --install /usr/bin/rmic rmic /usr/java/default/bin/rmic 2000
    alternatives --install /usr/bin/rmid rmid /usr/java/default/bin/rmid 2000
    alternatives --install /usr/bin/rmiregistry rmiregistry /usr/java/default/bin/rmiregistry 2000
    alternatives --install /usr/bin/schemagen schemagen /usr/java/default/bin/schemagen 2000
    alternatives --install /usr/bin/serialver serialver /usr/java/default/bin/serialver 2000
    alternatives --install /usr/bin/servertool servertool /usr/java/default/bin/servertool 2000
    alternatives --install /usr/bin/tnameserv tnameserv /usr/java/default/bin/tnameserv 2000
    alternatives --install /usr/bin/wsgen wsgen /usr/java/default/bin/wsgen 2000
    alternatives --install /usr/bin/wsimport wsimport /usr/java/default/bin/wsimport 2000
    alternatives --install /usr/bin/xjc xjc /usr/java/default/bin/xjc 2000
    
    You can copy-paste the above lines in a text file and then run the script in root mode.
  8. You must now choose an alternative to the default java configuration :
    # alternatives --config java
    
    Il existe 2 programmes qui fournissent « java ».
    
      Sélection    Commande
    -----------------------------------------------
     + 1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
    *  2           /usr/java/default/bin/java
    
    Entrez pour garder la sélection courante [+] ou saisissez le numéro de type de sélection : 2
    
  9. Check the java version
    # java -version
    java version "1.6.0_18"
    Java(TM) SE Runtime Environment (build 1.6.0_18-b03)
    Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
    
  10. Set the JAVA_HOME environment variable for all users. At the end of the file /etc/profile/, add the following lines :
    export JAVA_HOME="/usr/java/default"
    
  11. Done

Windows Installation

Installing Sun JDK

  1. If you are not sure whether you have Sun's JDK installed correctly, please confirm by doing the following :
    • Run a complete directory search (using the 'All File and Folders' option if available) on your drives for the occurrence of 'jdk' in the filename.
    • If your results retrieve a folder with the name 'jdk' immediately followed by a series of version numbers (for example, jdk1.6.0_13), then your Sun JDK has been installed. You should double-check the contents of this folder to ensure that the installation files are intact. If you are unsure about this, proceed to step 2 to re-install the Sun JDK. Otherwise, proceed to step 3 to check that your JAVA_HOME environment variable has been set correctly.
    • If you do not retrieve a result like this, then it is highly likely that your Sun JDK has not been installed.
  2. To install the Sun JDK, follow these instructions :
    • Go to the Java Sun download page.
    • Download the version entitled 'JDK 6 Update XX', where 'XX' stands for some number. (Sun will provide the latest version on that page.)
    • When the download has finished, run the Java installer. At one point, you will be asked to choose a directory to install to. Copy or write this directory down for use later.
  3. Check that the JAVA_HOME environment variable has been set correctly.
    • Open the 'Start' menu, choose 'Run', type cmd in the 'Run' dialog box and click the 'OK' button.
    • In the command prompt window, type echo %JAVA_HOME% and then press Enter.
    • View the result :
      • If a directory path is display that looks similar to one of the following examples, with the letters 'jdk' immediately preceding a series of version numbers, and this path matches the location where you installed the Sun JDK in step 2, then your Sun JDK has been successfully installed and your JAVA_HOME environment variable has been set correctly.
        Examples of typical JAVA_HOME environment variable values :
        • C:\Program Files\Java\jdk1.6.0_13
        • C:\Progra~1\Java\jdk1.6.0_13
        • C:\Java\jdk1.6.0_13
        • C:\jdk1.6.0_13
    • If nothing is displayed or you do not see 'jdk' immediately followed by a series of version numbers (like one of the examples above), then you need to set the JAVA_HOME environment variable. Please follow the instructions below to set your JAVA_HOME environment variable to the directory you where you have just installed the JDK. By default, this directory is under C:\Program Files\Java.
  4. Done
Note
Sometimes, Windows make a copy of the java executables in the C:\Windows\System32 directory. If theses are present, these are the one who are run by default.

Setting the JAVA_HOME Variable in Windows

Locate the JDK Installation Directory

If you already know the installation path for the Java or Software Development Kit, go to Stage 2 below. Otherwise, find the installation path by following these instructions :

  1. Unless you changed the installation path for the Java Development Kit during installation, it will be in a directory under C:\Program Files\Java. Using Explorer, open the directory C:\Program Files\Java.
  2. Inside that path will be one or more subdirectories such as jdk1.6.0_13. If you have just installed the Java Development Kit, it will be installed to the newest directory, which you can find by sorting by date. For example, it may be installed in C:\Program Files\Java\jdk1.6.0_13. This is the installation path.

Set the JAVA_HOME Variable

Once you have identified the JDK installation path :

  1. Right-click the My Computer icon on your desktop and select 'Properties'.
  2. Click the 'Advanced' tab.
  3. Click the 'Environment Variables' button.
  4. Under 'System Variables', click 'New'.
  5. Enter the variable name as JAVA_HOME.
  6. Enter the variable value as the installation path for the Java Development Kit.
  7. Click 'OK'.
  8. Click 'Apply Changes'.
Contributors
No contributors found for: authors on selected page(s)
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.