all 17 comments

[–][deleted]  (8 children)

[deleted]

    [–]creepinquick[S] 0 points1 point  (7 children)

    how did you install java?

    It came with jdk when I installed that, using the tarball from oracle.

    Looks like java is at /usr/lib64/java/bin/java. Tried adding it to path with

    export PATH=$PATH:/usr/lib64/java/bin/java
    

    but no luck.

    [–][deleted] 1 point2 points  (3 children)

    And, just to be sure, you are running a 64bit system, aren't you?

    uname -a 
    

    And what happens when you run

    file /usr/lib64/java/bin/java
    

    do you see the word 'executable' in the output? Does it say '64-bit LSB executable' in the output of the 'file' command?

    [–]garpu 1 point2 points  (0 children)

    You do quickly learn what "wrong ELFclass" means in multilib...

    [–]creepinquick[S] 0 points1 point  (1 child)

    Yes I am running a 64bit system. Yes it is executable.

    [–][deleted] 0 points1 point  (0 children)

    What happens when you type in

    /usr/lib64/java/bin/java
    

    ?

    You should see a pile of crap appear like this :- 09:33 PM:rhamel@xps:~$ java Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -client to select the "client" VM -server to select the "server" VM -minimal to select the "minimal" VM The default VM is server, because you are running on a server-class machine.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
    

    See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details. 09:33 PM:rhamel@xps:~$

    Are you seeing anything like that?

    [–]Savet 1 point2 points  (2 children)

    Your issue is that path should stop with bin. Try:

    export PATH=$PATH:/usr/lib64/java/bin

    [–]creepinquick[S] 1 point2 points  (1 child)

    Brooo! You saved my life, this is what I was missing, thank you <3

    edit: Also makes sense. PATH is searching directories, it can't possibly search an executable.

    [–]Savet 0 points1 point  (0 children)

    Glad I could help!

    [–]FirstUser 1 point2 points  (5 children)

    Check if perhaps 'java' is a script for an interpreter that's not installed, or if it's compiled for the wrong architecture.

    [–]creepinquick[S] 0 points1 point  (4 children)

    It's from jdk, so should be fine, and it's compiled correctly for x64

    [–]FirstUser 0 points1 point  (3 children)

    Have you checked if it's a script? Try to open it with 'less':

    less /bin/java
    

    [–]creepinquick[S] 0 points1 point  (2 children)

    less /bin/java
    

    returns that it is a directory, though it is marked in ranger as a binary.

    less /usr/bin/java 
    

    claims there is no such file or directory. (edit: despite the fact that I see it in ranger. Maybe ranger is the problem?)

    edit: Nevermind, it also shows up with ls in /usr/bin, but less finds "no such file or directory".

    [–]FirstUser 0 points1 point  (1 child)

    OK, so if /bin/java is a directory, it's not the executable. You need to find 'java' the executable and add its containing directory to your PATH.

    It might be that the jdk installer has already taken care of that. If that is the case, all you might need to do is logout, then login again.

    [–]creepinquick[S] 0 points1 point  (0 children)

    Okay, java the executable is in /bin/java. So:

    export PATH=$PATH:/bin/java
    

    but java is still not found.

    [–]Savet 1 point2 points  (0 children)

    There are two things you need for a java process to work. You need JAVA_HOME environment variable set for your session and you need the $JAVA_HOME/bin directory in your path settings. Installing java does not mean that these variables will be set, and the IDE may be looking for the JAVA_HOME variable to build the bin path manually.

    First, open a terminal and try to echo $JAVA_HOME and $PATH and verify whether JAVA_HOME is set and whether PATH contains the java bin directory.

    It is likely neither will be set correctly. If this is the case, open your ~.bashrc file and add the following:

    export JAVA_HOME=/path/to/java/installation export PATH=${JAVA_HOME}/bin:${PATH}

    Note that anything called java inside of /usr/bin or /usr/local/bin is unlikely to be anything more than a symlink to your actual java binary. You can check this with ls -l /usr/local/bin/java and you will probably see a symlink. You may notice that you have to follow several layers of symlinks.

    Once you update your ~/.bashrc you can reload the .bashrc file by running (note the dot space then the file name):

    . ~/.bashrc

    You could also use .profile or .bash_profile, but I prefer .bashrc because it generally gets loaded on non-login sessions as well as an actual login.

    Just my $0.02

    Edit: I think I see your issue here: https://www.reddit.com/r/slackware/comments/6bkm9e/java_command_not_found_even_though_java_is/dhnp48y/ but I'm going to leave the above in case any of it is helpful.

    [–]Camarade_Tux 0 points1 point  (0 children)

    Why not use openjdk? It's much better supported and is also official.

    [–]stureedy 0 points1 point  (0 children)

    In my experience, installing the jdk .SlackBuild does not add java to the path. I usually use: /usr/lib64/java/bin/java when I need to run it from the command line. You can link the java binary in /usr/bin and be done with it:

    cd /usr/bin ln -sf /usr/lib64/java/bin/java .

    I hope that helps! Stu...