JAVA_HOME is not set correctly after adding and appending to PATH
up vote
0
down vote
favorite
Ubuntu 14.04 LTS
Bash version 4.3.11(1)-release
I've added $JAVA_HOME to ~/.profile (and .bash_profile) like this:
#
# This is the default standard .profile provided to sh users.
# They are expected to edit it to meet their own needs.
#
# The commands in this file are executed when an sh user first
# logs in.
#
# $Revision: 1.10 $
#
# Set the interrupt character to Ctrl-c and do clean backspacing.
if [ -t 0 ]
then
stty intr '^C' echoe
fi
# Set the TERM environment variable
eval `tset -s -Q`
# Set the default X server.
if [ ${DISPLAY:-setdisplay} = setdisplay ]
then
if [ ${REMOTEHOST:-islocal} != islocal ]
then
DISPLAY=${REMOTEHOST}:0
else
DISPLAY=:0
fi
export DISPLAY
fi
# List files in columns if standard out is a terminal.
ls() { if [ -t ]; then /bin/ls -C $*; else /bin/ls $*; fi }
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
But still typing echo $JAVA_HOME yields:
XXX:~$ echo $JAVA_HOME
JAVA_HOME /usr/local/lib/jdk-8u25/
ubuntu bash java
add a comment |
up vote
0
down vote
favorite
Ubuntu 14.04 LTS
Bash version 4.3.11(1)-release
I've added $JAVA_HOME to ~/.profile (and .bash_profile) like this:
#
# This is the default standard .profile provided to sh users.
# They are expected to edit it to meet their own needs.
#
# The commands in this file are executed when an sh user first
# logs in.
#
# $Revision: 1.10 $
#
# Set the interrupt character to Ctrl-c and do clean backspacing.
if [ -t 0 ]
then
stty intr '^C' echoe
fi
# Set the TERM environment variable
eval `tset -s -Q`
# Set the default X server.
if [ ${DISPLAY:-setdisplay} = setdisplay ]
then
if [ ${REMOTEHOST:-islocal} != islocal ]
then
DISPLAY=${REMOTEHOST}:0
else
DISPLAY=:0
fi
export DISPLAY
fi
# List files in columns if standard out is a terminal.
ls() { if [ -t ]; then /bin/ls -C $*; else /bin/ls $*; fi }
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
But still typing echo $JAVA_HOME yields:
XXX:~$ echo $JAVA_HOME
JAVA_HOME /usr/local/lib/jdk-8u25/
ubuntu bash java
The most likely explanation is thatJAVA_HOME
is set again later in the initialisation file sequence. Trygrep JAVA_HOME .profile .bash*
to check. However,JAVA_HOME=$(/usr/bin/java)
is wrong: this setsJAVA_HOME
to the first token in the output from running/usr/bin/java
, but this generates help text on standard error and nothing on standard output, soJAVA_HOME
is set to an empty string.
– AFH
Nov 14 at 14:07
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Ubuntu 14.04 LTS
Bash version 4.3.11(1)-release
I've added $JAVA_HOME to ~/.profile (and .bash_profile) like this:
#
# This is the default standard .profile provided to sh users.
# They are expected to edit it to meet their own needs.
#
# The commands in this file are executed when an sh user first
# logs in.
#
# $Revision: 1.10 $
#
# Set the interrupt character to Ctrl-c and do clean backspacing.
if [ -t 0 ]
then
stty intr '^C' echoe
fi
# Set the TERM environment variable
eval `tset -s -Q`
# Set the default X server.
if [ ${DISPLAY:-setdisplay} = setdisplay ]
then
if [ ${REMOTEHOST:-islocal} != islocal ]
then
DISPLAY=${REMOTEHOST}:0
else
DISPLAY=:0
fi
export DISPLAY
fi
# List files in columns if standard out is a terminal.
ls() { if [ -t ]; then /bin/ls -C $*; else /bin/ls $*; fi }
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
But still typing echo $JAVA_HOME yields:
XXX:~$ echo $JAVA_HOME
JAVA_HOME /usr/local/lib/jdk-8u25/
ubuntu bash java
Ubuntu 14.04 LTS
Bash version 4.3.11(1)-release
I've added $JAVA_HOME to ~/.profile (and .bash_profile) like this:
#
# This is the default standard .profile provided to sh users.
# They are expected to edit it to meet their own needs.
#
# The commands in this file are executed when an sh user first
# logs in.
#
# $Revision: 1.10 $
#
# Set the interrupt character to Ctrl-c and do clean backspacing.
if [ -t 0 ]
then
stty intr '^C' echoe
fi
# Set the TERM environment variable
eval `tset -s -Q`
# Set the default X server.
if [ ${DISPLAY:-setdisplay} = setdisplay ]
then
if [ ${REMOTEHOST:-islocal} != islocal ]
then
DISPLAY=${REMOTEHOST}:0
else
DISPLAY=:0
fi
export DISPLAY
fi
# List files in columns if standard out is a terminal.
ls() { if [ -t ]; then /bin/ls -C $*; else /bin/ls $*; fi }
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
But still typing echo $JAVA_HOME yields:
XXX:~$ echo $JAVA_HOME
JAVA_HOME /usr/local/lib/jdk-8u25/
ubuntu bash java
ubuntu bash java
asked Nov 14 at 13:31
DsCpp
1032
1032
The most likely explanation is thatJAVA_HOME
is set again later in the initialisation file sequence. Trygrep JAVA_HOME .profile .bash*
to check. However,JAVA_HOME=$(/usr/bin/java)
is wrong: this setsJAVA_HOME
to the first token in the output from running/usr/bin/java
, but this generates help text on standard error and nothing on standard output, soJAVA_HOME
is set to an empty string.
– AFH
Nov 14 at 14:07
add a comment |
The most likely explanation is thatJAVA_HOME
is set again later in the initialisation file sequence. Trygrep JAVA_HOME .profile .bash*
to check. However,JAVA_HOME=$(/usr/bin/java)
is wrong: this setsJAVA_HOME
to the first token in the output from running/usr/bin/java
, but this generates help text on standard error and nothing on standard output, soJAVA_HOME
is set to an empty string.
– AFH
Nov 14 at 14:07
The most likely explanation is that
JAVA_HOME
is set again later in the initialisation file sequence. Try grep JAVA_HOME .profile .bash*
to check. However, JAVA_HOME=$(/usr/bin/java)
is wrong: this sets JAVA_HOME
to the first token in the output from running /usr/bin/java
, but this generates help text on standard error and nothing on standard output, so JAVA_HOME
is set to an empty string.– AFH
Nov 14 at 14:07
The most likely explanation is that
JAVA_HOME
is set again later in the initialisation file sequence. Try grep JAVA_HOME .profile .bash*
to check. However, JAVA_HOME=$(/usr/bin/java)
is wrong: this sets JAVA_HOME
to the first token in the output from running /usr/bin/java
, but this generates help text on standard error and nothing on standard output, so JAVA_HOME
is set to an empty string.– AFH
Nov 14 at 14:07
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You used:
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
Using the variable assignment with a $()
tells Linux to do a command substitution. So, it is trying to run the command /usr/bin/java
and assign the output to the variable.
You should use:
export JAVA_HOME=/usr/bin/java
export PATH=$JAVA_HOME/jre/bin:$PATH
Then to make the new variables live, execute your profile script:
. ~/.profile
Note the extra .
at the beginning. Without it the variable assignment would only persist within the scope of the script.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You used:
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
Using the variable assignment with a $()
tells Linux to do a command substitution. So, it is trying to run the command /usr/bin/java
and assign the output to the variable.
You should use:
export JAVA_HOME=/usr/bin/java
export PATH=$JAVA_HOME/jre/bin:$PATH
Then to make the new variables live, execute your profile script:
. ~/.profile
Note the extra .
at the beginning. Without it the variable assignment would only persist within the scope of the script.
add a comment |
up vote
1
down vote
accepted
You used:
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
Using the variable assignment with a $()
tells Linux to do a command substitution. So, it is trying to run the command /usr/bin/java
and assign the output to the variable.
You should use:
export JAVA_HOME=/usr/bin/java
export PATH=$JAVA_HOME/jre/bin:$PATH
Then to make the new variables live, execute your profile script:
. ~/.profile
Note the extra .
at the beginning. Without it the variable assignment would only persist within the scope of the script.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You used:
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
Using the variable assignment with a $()
tells Linux to do a command substitution. So, it is trying to run the command /usr/bin/java
and assign the output to the variable.
You should use:
export JAVA_HOME=/usr/bin/java
export PATH=$JAVA_HOME/jre/bin:$PATH
Then to make the new variables live, execute your profile script:
. ~/.profile
Note the extra .
at the beginning. Without it the variable assignment would only persist within the scope of the script.
You used:
export JAVA_HOME=$(/usr/bin/java)
export PATH=$JAVA_HOME/jre/bin:$PATH
Using the variable assignment with a $()
tells Linux to do a command substitution. So, it is trying to run the command /usr/bin/java
and assign the output to the variable.
You should use:
export JAVA_HOME=/usr/bin/java
export PATH=$JAVA_HOME/jre/bin:$PATH
Then to make the new variables live, execute your profile script:
. ~/.profile
Note the extra .
at the beginning. Without it the variable assignment would only persist within the scope of the script.
answered Nov 14 at 13:48
Appleoddity
6,78121024
6,78121024
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1375322%2fjava-home-is-not-set-correctly-after-adding-and-appending-to-path%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The most likely explanation is that
JAVA_HOME
is set again later in the initialisation file sequence. Trygrep JAVA_HOME .profile .bash*
to check. However,JAVA_HOME=$(/usr/bin/java)
is wrong: this setsJAVA_HOME
to the first token in the output from running/usr/bin/java
, but this generates help text on standard error and nothing on standard output, soJAVA_HOME
is set to an empty string.– AFH
Nov 14 at 14:07