echo $JAVA_HOME not returning jdk location
Asked Answered
S

4

26

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?

Stalwart answered 29/4, 2014 at 18:8 Comment(0)
D
37

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.

Dobbs answered 29/4, 2014 at 18:12 Comment(0)
E
6

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/

Endearment answered 11/8, 2017 at 1:20 Comment(1)
Take a deep breath and refer this link on how do I write a good answer.Irremissible
I
1

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
Indented answered 30/7, 2021 at 8:29 Comment(0)
O
-1

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

Override answered 21/1, 2016 at 19:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.