0% found this document useful (0 votes)
9 views1 page

Java Installation Command Descriptions

The document provides a step-by-step guide for installing Java on Linux using Windows Subsystem for Linux (WSL). It includes commands for installing WSL, updating the package index, installing JDK versions 8 and 11, and configuring environment variables. Additionally, it explains how to verify the installation and set up the terminal environment for Java development.

Uploaded by

mohammadseem1435
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Java Installation Command Descriptions

The document provides a step-by-step guide for installing Java on Linux using Windows Subsystem for Linux (WSL). It includes commands for installing WSL, updating the package index, installing JDK versions 8 and 11, and configuring environment variables. Additionally, it explains how to verify the installation and set up the terminal environment for Java development.

Uploaded by

mohammadseem1435
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Installation on Linux (WSL) - Command

Descriptions

wsl --install
Installs Windows Subsystem for Linux (WSL) along with the default Linux distribution (Ubuntu if not
specified). Enables Linux to run natively inside Windows without VirtualBox/VMware. Run in
PowerShell as Administrator.

sudo apt update


Updates the package index on Ubuntu so you can download the latest versions of software.
Connects to Ubuntu’s repository servers and fetches the latest list of available packages.

sudo apt install openjdk-8-jdk -y


Installs the Java Development Kit (JDK) version 8, including compiler (javac) and runtime (java).
The -y flag automatically confirms the installation without prompting.

sudo apt install openjdk-11-jdk -y


Installs Java Development Kit (JDK) version 11. Similar to the above, but for version 11.

java -version
Checks if Java is installed and shows the installed version along with build details.

nano ~/.bashrc
Opens the .bashrc file in the Nano text editor. This file contains shell configuration commands that
run every time you start a terminal.

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Defines the Java installation directory path as an environment variable JAVA_HOME, allowing
applications to locate Java.

export PATH=$JAVA_HOME/bin:$PATH
Adds Java’s bin directory to your PATH, enabling you to run Java commands like java and javac
from anywhere without specifying the full path.

source ~/.bashrc
Reloads the .bashrc file so that changes to environment variables take effect immediately without
restarting the terminal.

echo $JAVA_HOME
Prints the current value of the JAVA_HOME environment variable to confirm it’s set correctly.

You might also like