Setting Up Java and Ant Environment Variables

This article outlines how to setup the necessary environment variables to use Liferay portal and Plugins SDK. The article includes directions for both Windows and Ubuntu.

Resolution

Setup Java Home

Windows OS

  1. Go to the Java download page and download the JDK installer.
  2. Install the Java JDK. In this example, the base directory was C:/java (note the lowercase). The default directories should be fine, but problems have been encountered in setting ${JAVA_HOME} when installing to C:/Program Files (x86); it is possible that some programs don't like the spaces or the "(" and ")" symbols.
  3. Go to Windows Control Panel > System > Advanced system settings > Environmental Variables. This is for Windows Vista and Windows 7. For Windows XP, the path is Control Panel > System > Advanced > Environmental Variables. In all three versions of Windows, right clicking on My Computer > Properties will allow the Control Panel to be bypassed.
  4. In the lower portion (System Variables), click New and enter the following information:
    1. Variable name: JAVA_HOME
    2. Variable value: the path to the installed JDK (e.g., C:/java/jdk1.6.0_25).

  5. Find the variable Path in System variables and click Edit. Take care not to affect anything else that is present. Move to the beginning of the variable field and add in: %JAVA_HOME%/bin;
  6. Note the semi-colon, as it delimits the different variables present.

Ubuntu

  1. Open a terminal.
  2. Enter sudo add-apt-repository ppa:sun-java-community-team/sun-java6 ; apt-get update ; apt-get install sun-java6-jdk

Setup Ant Home

Windows OS

  1. Go to the Apache Ant page and download the Ant binary. Note that the zip file is best for Windows.# Unzip the file to a directory. It is best to keep the directory name short or memorable, like apache-ant-1.8.2
  2. Go to Windows Control Panel > System > Advanced system settings > Environmental Variables. This is for Windows Vista and Windows 7. For Windows XP, the path is Control Panel > System > Advanced > Environmental Variables. In all three versions of Windows, right clicking on My Computer > Properties will allow the Control Panel to be bypassed.
  3. Click New and enter the following information in the lower portion (System Variables):
    • Variable name: ANT_HOME
    • Variable value: the path of the installed JDK (e.g., C:/apache-ant-1.8.2).

  4. Create another System Variable and enter the following information
    • Variable name: ANT_OPTS
    • Variable value: -Xmx1024m -XX:MaxPermSize=256m
  5. Find the variable Path in System variables and click Edit. Take care not to affect anything else that is present. Move to the beginning of the variable field and add in %ANT_HOME%\bin;
  6. Note the semi-colon, as it delimits the different variables present.

Ubuntu

  1. Open a terminal.
  2. Enter apt-get install ant

Additional Information

A prerequisite for running any Liferay bundle is that you have the proper version of the Java Development Kit (1.5 or higher) installed on the machine to which you are installing Liferay. Make sure that you have also created the JAVA_HOME environment variable and have pointed it to your Java installation. While recent versions of Liferay bundle come packaged with a JRE (eliminating the need for a JAVA_HOME), most enterprises will not be using the bundle.

A prerequisite for using Plugins SDK is that you need to have Apache Ant installed on the development machine. Make sure that you have created the ANT_HOME environment variable and have pointed it to your Ant installation.

Was this article helpful?
0 out of 0 found this helpful