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.
- Download a JDK installation package such as jdk-8uversion-linux-x64.tar.gz from the Oracle official website.
- Go to the directory where the installation package resides.
- Use the following command to extract the installation package.
tar zxvf jdk-8uversion-linux-x64.tar.gz
- Perform the following steps to configure environment variables.
- Use the following command to open the configuration file.
vim ~/.bashrc
- 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
- Use the following command to enable the configuration.
source ~/.bashrc
- Use the following command to verify the installation result.
java -version javac -version
- Use the following command to open the configuration file.
macOS
- Download a JDK installation package such as jdk-8uversion-macosx-x64.dmg from the Oracle official website.
- Go to the directory where the installation package resides, double-click the installation package, and follow the provided instructions to install the JDK.
- Perform the following steps to configure environment variables.
- Use the following command to open the configuration file.
vim ~/.bashrc
- 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
- Use the following command to enable the configuration.
source ~/.bashrc
- Use the following command to verify the installation result.
java -version javac -version
- Use the following command to open the configuration file.
Windows
- Download a JDK installation package such as jdk-8version-windows-x64.exe from the Oracle official website.
- Go to the directory where the installation package resides, double-click the installation package, and follow the provided instructions to install the JDK.
- Perform the following steps to configure environment variables.
- Configure the JAVA_HOME environment variable.
C:\Program Files\Java\jdk1.8.0_73
- 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
- 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;
- Use the following command to verify the installation result.
java -version
- Configure the JAVA_HOME environment variable.
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.