hammad hammad - 1 year ago 150
Java Question

java command not found on remote machines linux

i try to run spark application on a cluster standalone mode, when i access to some remote machines and use "java -version" command i get the information(java version ..), but on others i get an error

-bash: command not found

so i thought that maybe java is not installed on those nodes so i tried with:

sudo apt -get install openjdk-8-jdk

but i get the same error, so wanna know how can i fix this, and i have some questions:

-Is it necessary that i install java on all remote machines? or if i install it only on the master node it is enough?

-if i have to install it on each node, how can i fix the problem that i explained before? (can not use install command...)

-In my code, i used expressions that are only supported with jdk 8, but some nodes (in which i could get "java version") it is installed jdk7, so do i have to reinstall jdk8 ?

Answer Source

"command not found" error means that particular command you're trying to invoke is not found in neither of directories listed in $PATH system variable.

There are two ways how to fix this:

1) Specify full path when running an executable:

/opt/jdk-12345/bin/java -version

2) add the very same path to PATH:

export PATH=$PATH:/opt/jdk-12345/bin
java -version

To fix this permanently, add that line (export PATH=$PATH:/opt/jdk-12345/bin) to ~/.bashrc (if BASH is default shell for that user) or to ~/.profile

Also because this is Unix Java, make sure to set up LD_LIBRARY_PATH and CLASSPATH variables if you're running some server applications. Usually this is done in application startup scripts, no need to go global.

Please verify which Server OS you're running ( uname -a or /bin/uname -a ) because different Unix systems have different package managers: apt-get is for Ubuntu/Debian, rpm for RedHat, Entropy for Sabayon/Gentoo, etc...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download