Java Environment Setup using VSCode and JDK for Windows, Linux, and macOS

Nishan Singh
2 min readDec 31, 2023

Java is widely used for software development, especially large enterprise backend software. It is a programming language that has been there for a long time. And even with multiple new trendy languages that cause the hype from time to time, JAVA is going nowhere. That makes learning Java a crucial step for most developers, and in this guide, we will walk you through the process for Windows, Linux, and macOS using Visual Studio Code (VSCode) and the Java Development Kit (JDK).

Installing Java Development Kit (JDK)

Windows

1. Download the latest JDK for Windows from the official Oracle website.(https://www.oracle.com/java/technologies/downloads/)

2. Run the installer and follow the on-screen instructions.

3. Set the JAVA_HOME environment variable:

  • Right-click on This PC or My Computer and select Properties.
  • Click on “Advanced system settings” on the left.
  • Click on the “Environment Variables” button.
  • Under System variables, click “New” and add a variable named JAVA_HOME with the path to your JDK installation (e.g., C:\Program Files\Java\jdk1.8.0_301)

Linux (Ubuntu)

  1. Open a terminal window.
  2. Run the following commands (this will install Java 21 to your system):
wget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.deb
sudo apt install ./jdk-21_linux-x64_bin.deb

Done.

Also, If you are using Arch/Kali or some other distro of Linux, you don’t need a blog to learn how to install JAVA :D

macOS

Install Homebrew if you haven’t already:

 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install OpenJDK using Homebrew:

brew install openjdk@11

Set the JAVA_HOME environment variable:

echo 'export JAVA_HOME=/usr/local/opt/openjdk@11' >> ~/.zshrc
source ~/.zshrc

--

--