Having recently setup a Cassandra environment for a customer I found it would crash with a segmentation fault. I discovered this was due to the OpenJDK that is bundled with CentOS – as a workaround I installed the Sun Oracle JDK using the steps below:
- Download the appropriate file (e.g jdk-7u45-linux-x64.rpm) JDK from Oracle website. Exact as necessary and install JDK rpm:
sudo yum localinstall jdk-.rpm
- Add java as alternative for /usr/bin/java:
sudo alternatives --install /usr/bin/java java /usr/java/latest/bin/java <priority>
Note: Default priority of open-jdk is 16000. A higher priority must be selected. - To add JAVA_HOME to environment variables create /etc/profile.d/java.sh containing the following:
export JAVA_HOME=<java_home>
Note: If Oracle JDK is installed is /usr/java/latest
Load into current session:
source /etc/profile.d/java.sh
Verify
echo $JAVA_HOME
- Verify installation
Command:
java -version
Output:
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)