3

I downloaded java-8 and amd combined package for working with Cassandra in linux. When I run cassandra, it is showing as- Unable to find java executable. Check JAVA_HOME and PATH environment variables.

How to correctly set those variables?

Madhuri
  • 73
  • 1
  • 1
  • 7

5 Answers5

2

Open ~/.bashrc and add

export JAVA_HOME=<path to your java>
export PATH=<path to your java>:$PATH

with the path where your java is and then reopen terminal or execute source ~/.bashrc

Filipp Voronov
  • 4,077
  • 5
  • 25
  • 32
1

Correct solution is:

  • Open ~/.bashrc file
  • Add to this file 2 lines as below:
export JAVA_HOME=Path_to_Java_installation_folder
export PATH=$JAVA_HOME/bin:$PATH

in the bottom.

Logoff and login again, then check the result.

1

To setup environment variable just follow some steps from root user:

# vi /etc/profile.d/java.sh

Add the following lines to the java.sh file-

export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH

After adding those lines to java.sh, save and exit. Then-

# source /etc/profile.d/java.sh

For cassandra environment variable setup: https://stackoverflow.com/a/39940053/4610541

Community
  • 1
  • 1
Anower Perves
  • 754
  • 8
  • 15
0

sudo vim /etc/profile

add at the last sucu as: export JAVA_HOME=/home/software/jdk1.8.0_71

export PATH=$JAVA_HOME/bin:$PATH

flgang
  • 104
  • 5
0

You can add this code to /etc/profile file

JAVA_HOME=<Path to JDK folder>
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

You can refer to this article Install JDK in ubuntu