Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Installing and Configuring JDK 11 on Linux Systems

Tech 2

Downloading JDK 11 from Oracle

Download the JDK 11 installation package (tar.gz or rpm) from the Oracle website and proceed with the installation.

Using tar.gz Package

wget https://download.oracle.com/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz
tar -zxvf openjdk-11.0.2_linux-x64_bin.tar.gz

Setting Environment Variables

Configure the JAVA_HOME and PATH environment variibles:

export JAVA_HOME=/path/to/jdk-11.0.2
export PATH=$JAVA_HOME/bin:$PATH

Three Methods for Configuring Environment Variables

Method 1: Using the /etc/profile File

  1. Open a terminal and edit the /etc/profile file:
sudo vi /etc/profile
  1. Add the following content at the end of the file:
export JAVA_HOME=/usr/lib/jvm/jdk1.x.x  # Modify based on your JDK installation path
export PATH=$PATH:$JAVA_HOME/bin

Note: Replace "jdk1.x.x" with your actual JDK version number.

  1. Save and exit the file.

  2. Apply the configuraton:

source /etc/profile
  1. Verify the configuration by checking the JDK version:
java -version

Method 2: Using the ~/.bashrc File

  1. Open a terminal and edit the ~/.bashrc file:
vi ~/.bashrc
  1. Add the following content at the end of the file:
export JAVA_HOME=/usr/lib/jvm/jdk1.x.x  # Modify based on your JDK installation path
export PATH=$PATH:$JAVA_HOME/bin

Note: Replace "jdk1.x.x" with your actual JDK version number.

  1. Save and exit the file.

  2. Apply the configuration:

source ~/.bashrc
  1. Verify the configuration by checking the JDK vertion:
java -version

Method 3: Using the /etc/environment File

  1. Open a terminal and edit the /etc/environment file:
sudo vi /etc/environment
  1. Add the following content to the file:
JAVA_HOME="/usr/lib/jvm/jdk1.x.x"  # Modify based on your JDK installation path
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin"

Note: Replace "jdk1.x.x" with your actual JDK version number.

  1. Save and exit the file.

  2. Apply the connfiguration:

source /etc/environment
  1. Verify the configuration by checking the JDK version:
java -version

Conclusion

Using any of the three methods above, you can successfully configure JDK environment variables on a Linux system. Regardless of which method you choose, you must modify the paths according to your actual JDK installation. Once configured, you can directly use Java commands in the terminal and run Java applications smoothly.

Tags: LinuxJDK

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.