.. _geoserver.install.java_install:

Installing Java
---------------

GeoServer runs on the `Java <http://www.java.com>`_ geoserver platform. This section covers the installation of the Java Development Kit (JDK) that is necessary to run GeoServer.

#. Navigate to the workshop :file:`software` directory.

#. Run the Java Development Kit installer by *double-clicking* on the file named :file:`jdk-1_5_0_14-windows-i586-p.exe`, or alternatively by *right-clicking* on the file and selecting :guilabel:`Open`.

   .. note::  Running GeoServer requires a Java Development Kit (JDK), not just a Java Runtime Environment (JRE).

   .. figure:: java_install1.jpg

      Running the Java installer      

#. Accept the :guilabel:`License Agreement` and click :guilabel:`Next`.

   .. figure:: java_install2.jpg

      Reviewing the Java license agreement

#. On the :guilabel:`Custom Setup` screen, disable the :guilabel:`Public JRE` feature and click :guilabel:`Next`.

   .. note::  A JRE is often installed by other applications on the system. To prevent a conflict the Public JRE option should be **disabled**.

   .. figure:: java_install3.jpg

      Disabling the public Java Runtime Environment

#. Exit the installer by clicking :guilabel:`Finish`.

Setting the JAVA_HOME Environment Variable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Certain applications such as GeoServer rely on the existence of an environment variable named ``JAVA_HOME`` in order to run. This environment variable points to the Java installation on the system. This section covers the task of defining the ``JAVA_HOME`` environment variable.

#. On the desktop *right-click* the :guilabel:`My Computer:guilabel:` icon. 

   .. figure:: java_install4.jpg

      Opening My Computer properties from the desktop

   .. note:: Depending on the Windows configuration the :guilabel:`My Computer` icon may only exist in the :guilabel:`Start Menu`.

        .. figure:: java_install5.jpg
           :align: center

           Opening My Computer properties from the start menu

#. Open the :guilabel:`Advanced:guilabel:` tab and click the :guilabel:`Environment Variables` button.

   .. figure:: java_install6.jpg

      Adding an environment variable  

#. In the :guilabel:`Environment Variables:guilabel:` dialog click the :guilabel:`New` button and define a new variable called "JAVA_HOME" that points to the JDK installed in the previous section.

   .. figure:: java_install7.jpg

      Defining the JAVA_HOME environment variable

#. Click :guilabel:`OK` to add the ``JAVA_HOME`` variable, and then :guilabel:`OK` to close the **Environment Variables** dialog.

At this point Java is installed on the system. To verify the installation and configuration of the ``JAVA_HOME`` variable start a windows command line and execute the following command::
  
   %JAVA_HOME%\bin\java -version

The command should return output similar to the following::

   java version "1.5.0_21"
   Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_21-b01)
   Java HotSpot(TM) Client VM (build 1.5.0_21-b01, mixed mode, sharing)

If it does not Java is not installed correctly on the system.


