• Java JDK path environment variables (Path issues).


    I have installed both the JDK and java-commons from the AUR and I wanted to test it however I ran into an issue when trying to use:

    javac file.java
    
    bash: javac: command not found
    

    So i suspected it was a pathing issue. The command java works fine and so I checked the installation,

    java -version
    
    java version "1.8.0_144"
    Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
    Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
    

    And it appears the JDK is not listed. Does this mean I don’t have the JDK installed? Because when I use the add/remove software client it only has the option to remove the JDK.

    The relevant path working for just the command “java” is:

    echo $PATH
    
    /usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cuda/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
    
    /usr/lib/jvm/default/bin
    

    Which I assume is the JAVA_HOME variable.

    The installed (apparently not) JDK 8.0 is on the path:

    /usr/lib/jvm/java-8-openjdk
    

    and the javac script inside:

    /usr/lib/jvm/java-8-openjdk/bin
    

    Inside this bin file, it also contains the normal “java” run script. So I have tried to change this variable using,

    gedit ~/.bashrc
    

    And adding this to the bottom

    JAVA_HOME=/usr/lib/jvm/java-8-openjdk/bin
    

    However this changes nothing, even on restarting the computer.

    I have also tried simply adding the JDK path variable into $PATH to no avail. (With and without export at the front)

    PATH=$PATH:~/usr/lib/jvm/java-8-openjdk/bin
    

    I found this: https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path).
    The top answer says to not use ~/.bashrc, rather to use ~/.profile or ~/.bash_profile. I have opened both the latter config files but they appear to be both empty or non-existent.

    I really am inclined to just reinstall everything at this point (Will that even change anything?) but I want to just make sure I have actually tried everything before I do so.

    Any help much appreciated, thanks.

  • UPDATE:

    echo $JAVA_HOME
    

    gives me.

    /usr/lib/jvm/java-8-openjdk/bin
    

    This is correct, however javac on the command line still not recognised.

    Java on Eclipse also works fine. This is really weird… Am i missing something very simple?

  • Okay, I’m not sure why this didn’t work earlier but I assume it was because that I was restarting my computer rather than the terminal.

    This is what I did:

    gedit ~/.bashrc
    

    And added these two lines, then restarted terminal (NOT COMPUTER)

    JAVA_HOME=/usr/lib/jvm/java-8-openjdk/bin
    export PATH=$PATH:$JAVA_HOME
    

    I should really read more carefully.

java8 environment6 path4 jdk1 Posts 3Views 420
Log in to reply
Bloom Email Optin Plugin

Looks like your connection to Antergos Community Forum was lost, please wait while we try to reconnect.