View Source

{section}
{column}

h1. Preamble

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

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

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

h1. Linux Installation

h2. 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 :

{table-plus}
|| Distribution || Java Installation Guide ||
| CentOS | [http://wiki.centos.org/HowTos/JavaOnCentOS|http://wiki.centos.org/HowTos/JavaOnCentOS] (english)|
| Debian | [http://wiki.debian.org/Java|http://wiki.debian.org/Java] (english)|
| Fedora / RedHat | [http://doc.fedora-fr.org/wiki/Java_Sun_:_Installation_(plugin,_JRE,_JDK)|http://doc.fedora-fr.org/wiki/Java_Sun_:_Installation_(plugin,_JRE,_JDK)] (french) |
| Ubuntu | [https://help.ubuntu.com/community/Java|https://help.ubuntu.com/community/Java] (english)\\
[https://help.ubuntu.com/community/JavaInstallation|https://help.ubuntu.com/community/JavaInstallation] (english) |
| Ubuntu Server | [https://help.ubuntu.com/community/Java|https://help.ubuntu.com/community/Java] (english)\\
[https://help.ubuntu.com/community/JavaInstallation|https://help.ubuntu.com/community/JavaInstallation] (english)|
{table-plus}

h2. Generic Installation Guide of the Sun JDK on Linux

# Create the JDK installation directory :
{noformat}
# mkdir /usr/java
{noformat}
# Copy the JDK binary in this directory :
{noformat}
# cp jdk-6u18-linux-x64.bin /usr/java
{noformat}
# Move into the JDK installation directory :
{noformat}
# cd /usr/java
{noformat}
By default, the downloaded binary can't be executed. You must give it the executions rights :
{noformat}
# chmod a+x jdk-6u18-linux-x64.bin
{noformat}
# Launch the installer :
{noformat}
# ./jdk-6u18-linux-x64.bin
{noformat} \\
(Press the space bar many times to go to the end of the licence contract and type {{yes}} then press the enter key).
# Remove all the installation binaries :
{noformat}
# rm -f *.rpm *.bin
{noformat}
# You then need to create 2 more directories (if they are not automatically created) :
{noformat}
# ln -sf /usr/java/jdk1.6.0_18/ /usr/java/current
# ln -sf /usr/java/jdk1.6.0_18/ /usr/java/latest
{noformat}
{note}
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
{note}
# You must now declare the alternatives for some executables as {{java}}, {{javac}}, ...
{noformat}
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
{noformat}
{note}
You can copy-paste the above lines in a text file and then run the script in root mode.
{note}
# You must now choose an alternative to the default java configuration :
{noformat}
# 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
{noformat}
# Check the java version
{noformat}
# 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)
{noformat}
# Set the {{JAVA_HOME}} environment variable for all users. At the end of the file */etc/profile/*, add the following lines :
{noformat}
export JAVA_HOME="/usr/java/default"
{noformat}
# Done :-)

h1. Windows Installation

h2. Installing Sun JDK

# 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.
# To install the Sun JDK, follow these instructions :
** Go to the [Java Sun download page|http://java.sun.com/javase/downloads/index.jsp].
** 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.
# 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}}.
# Done :-)

{note:title=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.
{note}

h2. Setting the JAVA_HOME Variable in Windows

h3. 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 :
# 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}}.
# 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.

h3. Set the JAVA_HOME Variable

Once you have identified the JDK installation path :
# Right-click the *My Computer* icon on your desktop and select '*Properties*'.
# Click the '*Advanced*' tab.
# Click the '*Environment Variables*' button.
# Under '*System Variables*', click '*New*'.
# Enter the variable name as {{JAVA_HOME}}.
# Enter the variable value as the installation path for the Java Development Kit.
# Click '*OK*'.
# Click '*Apply Changes*'.
{column}
{column:width=350px}
{panel:title=Table of contents}{toc}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list}{panel}
{column}
{section}