Basics

Java Installation

Installing Java

Java installation uses JDK for development with IDEs like IntelliJ.

Understanding Java and JDK

The Java Development Kit (JDK) is a software development environment used for developing Java applications. It includes the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools needed for Java development.

Downloading the JDK

To start using Java, you need to download and install the JDK. The latest version can be downloaded from the official Oracle website or from OpenJDK distributions.

Installing the JDK

After downloading the JDK, follow these steps to install it on your system:

  • Run the downloaded installer.
  • Follow the installation instructions. It is recommended to use the default settings.
  • Note the installation directory as you may need it later.

Setting JAVA_HOME Environment Variable

After installation, set the JAVA_HOME environment variable to point to the JDK directory:

  • On Windows, open the System Properties and add a new environment variable named JAVA_HOME with the value of your JDK installation path.
  • On macOS/Linux, add the following line to your ~/.bash_profile or ~/.bashrc:

Verifying the Installation

After setting the environment variable, verify the installation by opening a terminal or command prompt and typing:

If the installation was successful, you should see output displaying the Java version installed on your system.

Configuring IntelliJ IDEA

IntelliJ IDEA is a popular IDE for Java development. To configure IntelliJ with your JDK:

  • Open IntelliJ IDEA and go to File > Project Structure.
  • Under Platform Settings, select SDKs and click Add SDK.
  • Select JDK, then navigate to the JDK installation directory and click OK.

Your development environment is now set up to create and run Java applications using IntelliJ IDEA.