Reputation: 29
I have installed openjdk-8, so i can successfully check:
seva@seva-HLYL-WXX9:~$ java -version
openjdk version "1.8.0_432"
OpenJDK Runtime Environment (build 1.8.0_432-8u432-ga~us1-0ubuntu2~24.04-ga)
OpenJDK 64-Bit Server VM (build 25.432-bga, mixed mode)
seva@seva-HLYL-WXX9:~$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
seva@seva-HLYL-WXX9:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/opt/idea-IU-243.22562.218/bin:/usr/java/jdk1.8.0_431/bin:/opt/idea-IU-243.22562.218/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin
I also have installed cassandra 4.0 how its was described in documentation. But when i run cassandra
or nodetool
then i receive message:
seva@seva-HLYL-WXX9:~$ sudo cassandra
Unable to find java executable. Check JAVA_HOME and PATH environment variables.
Upvotes: 1
Views: 73
Reputation: 16353
If you installed Cassandra as a package, it runs as a service so you need to start it as such. For example:
$ sudo service cassandra start
Since you're starting it as a standalone process (with just the bin/cassandra
command), I'm assuming you installed Cassandra using the binary tarball.
When you attempt to run a command with sudo
, it forks a new process with a different user's environment (default user is root
unless specified). As @Stephen-C pointed out in the comments, that environment will have its own settings which isn't the same as the calling process so you need to configure root
with the appropriate environment settings so the Cassandra startup script can find where Java is installed.
To echo @Aaron, Cassandra does not require sudo
access since the standalone process does not have to run as root
. It can run as any regular user provided that user has read/write/execute permissions to the installation directory and its subdirectories.
As a side note, Java 11 support was added in Cassandra 4.0 (CASSANDRA-9608, CASSANDRA-16894) in case you weren't aware. Cheers!
Upvotes: 0