Easy Tutorial
❮ Keys Rename Transactions Discard ❯

Java Development Environment Setup

In this section, we will guide you through setting up a Java development environment.


Installing Java on Windows System

Download JDK

First, we need to download the Java Development Kit (JDK). The download link is: https://www.oracle.com/java/technologies/downloads/. On the download page, select the version corresponding to your system. This guide uses the Windows 64-bit system as an example:

After downloading, follow the prompts to install the JDK. During the installation, both JDK and JRE will be installed.

During the JDK installation, you can customize the installation directory, for example, C:\Program Files (x86)\Java\jdk1.8.0_91.

Configure Environment Variables

  1. After installation, right-click "This PC," click "Properties," and select "Advanced system settings."
  2. Select the "Advanced" tab and click "Environment Variables."

You will see a screen like the following:

In "System Variables," set three attributes: JAVA_HOME, PATH, and CLASSPATH (case insensitive). If they already exist, click "Edit"; if not, click "New."

Note: If you are using JDK version 1.5 or higher, you do not need to set the CLASSPATH environment variable to compile and run Java programs.

The variable settings are as follows:

JAVA_HOME Setup

PATH Setup

Note: In Windows 10, the Path variable is displayed in separate lines. We need to add %JAVAHOME%\bin;%JAVAHOME%\jre\bin; separately, otherwise it will not be recognized:

%JAVA_HOME%\bin;
%JAVA_HOME%\jre\bin;

For more details, refer to: Configuring Java Environment Variables on Windows 10

CLASSPATH Setup

This is the Java environment configuration. After completing this setup, you can start Eclipse to write code, and it will automatically configure the Java environment.

Testing JDK Installation

  1. Go to "Start" -> "Run" and type "cmd."
  2. Enter the commands: java -version, java, javac. If the following information appears, the environment variable configuration is successful.

Environment Variable Setup on Linux, UNIX, Solaris, FreeBSD

The environment variable PATH should be set to point to the location where the Java binary files are installed. If you encounter difficulties, refer to the shell documentation.

For example, if you are using bash as your shell, you can add the following line to the end of your .bashrc file: export PATH=/path/to/java:$PATH


Popular Java Development Tools

As the saying goes, "A workman is known by his tools." We also need a good development tool when developing Java. There are many IDEs on the market. This article recommends the following Java development tools:

-Netbeans: An open-source, free Java IDE, download link: http://www.netbeans.org/index.html

Running Your First Java Program with Eclipse

Video demonstration as follows:

HelloWorld.java file code:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

Running Java Programs in Cloud Studio

>

Java is a cross-platform programming language. To run Java programs on your computer, you need to install JRE, and to develop Java programs, you need to install JDK. This might be complex for beginners and issues may arise during the installation and configuration process. For experienced developers, there might be times when they need to temporarily develop and debug code on a computer without a Java environment. Therefore, it is recommended to use the online cloud-based development tool Cloud Studio based on Tencent Cloud to quickly start your Java project.

Tips: From the terminal commands, you can see that Cloud Studio integrates the Ubuntu16.04 + Java1.8 development environment:

For any questions, refer to the help documentation.

Currently, CODING is hosting a contest for the most favorite Cloud Studio plugins. Visit the event website: https://studio.qcloud.coding.net/campaign/favorite-plugins/index for more information.

❮ Keys Rename Transactions Discard ❯