Question

When I type in echo $JAVA_HOME, I get $JAVA_HOME instead of the location of the jdk. I set the path from the environment variables correctly:

Variable name : JAVA_HOME Variable value: C:\Program Files\Java\jdk1.7.0_25

what am I doing wrong?

Was it helpful?

Solution

Try echo %JAVA_HOME% instead of echo $JAVA_HOME.

The first is for Windows (I'm assuming it's windows based on your filepath), the one you're using is for Linux.

OTHER TIPS

In my case, when I typed "echo $JAVA_HOME" I was getting blank, and I resolved it by following these instructions:

$ vim .bash_profile

export JAVA_HOME=$(/usr/libexec/java_home)

$ source .bash_profile

$ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

Reference: https://www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/

In Ubuntu you may setup and confirm the environment variable like this:

~$ sudo apt install default-jdk
~$ sudo nano /etc/environment
# ADD below line
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
~$ source /etc/environment
~$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64

Above commands are:

  1. install jdk
  2. edit environment file
  3. apply edited environment variable
  4. show $JAVA_HOME

Linux:

$ vi ~/.bash_profile

export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

$ source ~/.bash_profile

Verification:

$ echo $JAVA_HOME

$ echo $PATH

$ which java

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top