Before testing Java applications in a local development environment, you must prepare the development environment. This topic describes how to configure a Java development environment. It also provides download links for related tools.

Install a JDK

If no specific requirement exists, we recommend that you download a Java development kit (JDK) installation package such as jdk-8uversion-linux-x64.tar.gz from the Oracle official website. You can download the latest JDK or a JDK that is compatible with your operating system. Then, use the following command to extract the installation package. After you download a JDK, you can perform the following steps specific to your operating system to install the JDK.

Linux
  1. Download a JDK installation package such as jdk-8uversion-linux-x64.tar.gz from the Oracle official website.
  2. Go to the directory where the installation package resides.
  3. Use the following command to extract the installation package.
    tar zxvf jdk-8uversion-linux-x64.tar.gz
  4. Perform the following steps to configure environment variables.
    1. Use the following command to open the configuration file.
      vim ~/.bashrc
    2. Add the following code to the configuration file.
      JAVA_HOME=/ <the Java installation path>
      CLASSPATH=$JAVA_HOME/lib/
      ENV PATH $PATH:$JAVA_HOME/bin
      export PATH=$JAVA_HOME/bin:$PATH
    3. Use the following command to enable the configuration.
      source ~/.bashrc
    4. Use the following command to verify the installation result.
      java -version
      javac -version

macOS

  1. Download a JDK installation package such as jdk-8uversion-macosx-x64.dmg from the Oracle official website.
  2. Go to the directory where the installation package resides, double-click the installation package, and follow the provided instructions to install the JDK.
  3. Perform the following steps to configure environment variables.
    1. Use the following command to open the configuration file.
      vim ~/.bashrc
    2. Add the following code to the configuration file.
      JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
      CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
      PATH=$JAVA_HOME/bin:$PATH:
      export JAVA_HOME
      export CLASSPATH
      export PATH
    3. Use the following command to enable the configuration.
      source ~/.bashrc
    4. Use the following command to verify the installation result.
      java -version
      javac -version

Windows

  1. Download a JDK installation package such as jdk-8version-windows-x64.exe from the Oracle official website.
  2. Go to the directory where the installation package resides, double-click the installation package, and follow the provided instructions to install the JDK.
  3. Perform the following steps to configure environment variables.
    1. Configure the JAVA_HOME environment variable.
      C:\Program Files\Java\jdk1.8.0_73
    2. Modify the PATH environment variable. Add the following paths to the variable.
      <the original paths specified in the PATH environment variable>;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
    3. Create an environment variable named CLASSPATH and add the following code to the variable.
      %JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
    4. Use the following command to verify the installation result.
      java -version

Install Tomcat

Visit the Apache Tomcat official website. Download a suitable Tomcat version based on the description that is provided in the Apache Tomcat Versions section.

Install an IDE

An integrated development environment (IDE) is a software application that provides developers with comprehensive tools for software development. Typically, these tools include a code editor, compiler, and debugger, and graphical user interface (GUI). If this is the first time that you are using an IDE to develop a Java application, we recommend you use either Eclipse or IntelliJ IDEA to develop Java applications based on your preference.