I execute the command sudo cassandra -R
to start cassandra
and I get the following error.
getopt: invalid option -- 'R'
/usr/sbin/cassandra: 158: exec: java: not found
It points to the following line in the cassandra script.
else
exec $NUMACTL "$JAVA" $JVM_OPTS $cassandra_parms -cp "$CLASSPATH"
Is it because the environment variable JAVA
is not set?
If yes, how to set the variable?
The output of echo $JAVA_HOME
is blank. This is the output of java -version
:
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
A simple solution for that is to set
JAVA_HOME
variable to point to your java installation. The cassandra script should generally autodeetect your java location onPATH
, but if it doesn't happen, you can help with settingJAVA_HOME
explicitly:Note: you must set
JAVA_HOME
notJAVA
.JAVA
variable is used internally by the cassandra launch scripts, but you're not supposed to set it.JAVA
is set by this code snippet incassandra.in.sh
: