Instagram Widget

Set JAVA_HOME path in ubuntu

Many a times after installing Java, JRE works fine as to run Java applications. But when it comes for Java development, JDK is required.

We get issues like 

- "The JAVA_HOME environment variable is not defined correctly. 
This environment variable is needed to run this program.
JAVA_HOME should point to a JDK not jre."

- "No compiler is provided in this environment. Perhaps you are running on a JRE rather than JDK"

- Maven unable to find JAVA_HOME.

To solve these issues on Ubuntu 18.04.

- Update apt : Advanced Package Tool

sudo apt update

- Install JDK: Skip if JDK already installed

sudo apt install openjdk-8-jdk


export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

- Check if JAVA_HOME is set


- Add Java bin to path variable

export PATH=$PATH:$JAVA_HOME/bin

- verify PATH

echo $PATH

- Verify Java setup

java -version

- Verify maven

mvn -v

If everything goes right your issue is solved and you are ready to dive into java development.

Post a Comment