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/









share|improve this question






















  • 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

















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/









share|improve this question






















  • 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















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/









share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 at 13:31









DsCpp

1032




1032












  • 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


















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












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.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 at 13:48









        Appleoddity

        6,78121024




        6,78121024






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Сан-Квентин

            Алькесар

            Josef Freinademetz