Setting the JAVA_HOME environment variable in Ubuntu

后端 未结 9 1878
渐次进展
渐次进展 2020-12-16 02:20

I\'m pretty new on ubuntu, at some point in the terminal I\'m running:

mortar local:illustrate pigscripts/retail-recsys.pig purchase_input -f params/retail.p         


        
相关标签:
9条回答
  • 2020-12-16 02:36
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle
    

    in your ~/.bashrc file.

    If you want this environment variable available to all users and on system start then you can add the following to /etc/profile.d/java.sh (create it if necessary):

    export JDK_HOME=/usr/lib/jvm/java-7-oracle
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle
    

    Then in a terminal run:

    sudo chmod +x /etc/profile.d/java.sh
    source /etc/profile.d/java.sh
    
    0 讨论(0)
  • 2020-12-16 02:37

    The simplest method to set environment variable is with export:

        $ export JAVA_HOME="/usr/bin"
    

    This will temporarily set the desired variable. You can check if it was set with:

        $ echo $JAVA_HOME
    

    or

        $ printenv
    

    If you want a more permanent solution, append 'export JAVA_HOME="/usr/bin"' to .bashrc or .bash_profile file.

    To check if java is properly installed:

        $ which java
        $ which javac
    

    You should get similar output:

        /usr/bin/java
    
    0 讨论(0)
  • 2020-12-16 02:40

    For JAVA_HOME to point to the active jdk, add to your ~/.bashrc

    export JAVA_HOME=$(update-alternatives --query javac | sed -n -e 's/Best: *\(.*\)\/bin\/javac/\1/p')
    

    which will dynamically set the $JAVA_HOME to the JDK selected by update-alternatives.

    0 讨论(0)
提交回复
热议问题