Easy Tutorial
❮ Data Add Dir Hierarchy ❯

Java Development Environment Setup

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


Installing Java on Windows

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 a 64-bit Windows system as an example:

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

When installing the JDK, 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 as shown below:

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

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

Variable settings are as follows:

JAVA_HOME Setting

PATH Setting

Note: In Windows 10, the Path variable is displayed in sections. 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 Setting

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 commands: java -version, java, javac. If you see the following information, the environment variable configuration is successful;

Linux, UNIX, Solaris, FreeBSD Environment Variable Setup

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 content 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." In developing Java, we also need a good development tool. There are many IDEs on the market. This article recommends the following Java development tools:

-

Eclipse (Recommended): Another free and open-source Java IDE. Download link: http://www.eclipse.org/downloads/packages/

Select Eclipse IDE for Java Developers: -JetBrains IDEA, now widely adopted by many, features powerful capabilities. Download link: https://www.jetbrains.com/idea/download/

-VSCode: VSCode (full name: Visual Studio Code) is a free, cross-platform source code editor developed by Microsoft. Installation guide: https://www.tutorialpro.org/w3cnote/vscode-tutorial.html

-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 the JRE, and to develop Java programs, you need to install the JDK. This might seem complex for beginners, and issues can arise during installation and configuration. For veterans, there may be times when they need to develop and debug code on an unfamiliar computer (without a Java environment). Therefore, Cloud Studio, an online development tool based on Tencent Cloud, is recommended 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 Plugin" based on Cloud Studio workspaces. Visit the event page: https://studio.qcloud.coding.net/campaign/favorite-plugins/index for more information.

❮ Data Add Dir Hierarchy ❯