Search code examples
javalinuxsuse

How to install java on Suse?


I'm trying to install java (jre 1.8) on Linux Suse,

I've downloaded the tar.gz file from oracle website and unzipped it.

Now I have java on my machine but I can only run it like that:

./java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

running the command by itself doesn't work:

/usr/java/jdk1.8.0_91/bin # java -version
If 'java' is not a typo you can run the following command to lookup the package that contains the binary:
    command-not-found java
-bash: java: command not found

enter image description here

So obviously I can't add to the PATH because it will not be recognized.

Does anyone know what am I missing?


Solution

  • Linux is not Windows. If you start a executable without a path the system will start it only if it's found in one of the directories specified in PATH.

    This means even if the executable you want to run is in your current directory it would not be executed if this directory is not in PATH. If you explicitly specify the directory the executable will be executed even the directory it's not in PATH.

    See some small examples.

    Following s assumed: /usr/java/jdk1.8.0_91/bin is not specified in PATH.

    cd /tmp
    java 
    

    Would fail as /tmp is not in PATH.

    cd /tmp
    ./java
    

    Would fail as there is (normally) no java executable in the /tmp directory.

    cd /usr/java/jdk1.8.0_91/bin
    java
    

    Would fail as /usr/java/jdk1.8.0_91/bin is not in PATH.

    cd /usr/java/jdk1.8.0_91/bin
    ./java
    

    Would be executed as you explicitly specify to run java found in the current directory ./.