且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

cassandra 2抱怨Java 7时安装了Java 7

更新时间:2023-01-14 23:15:24

当尝试启动Cassandra时,我得到了相同的错误消息。但我注意到,我只有当启动Cassandra作为根时的错误。当我开始Cassandra作为我的本地用户时,它工作。

I got the same error message when trying to start Cassandra. But I notised that I only got the error when starting Cassandra as root. It worked when I started Cassandra as my local user.

原来,只为我的本地用户配置了java:

It turned out that java only was configured for my local user:

$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
$ sudo java -version
sudo: java: command not found

这解决了问题:

告诉系统您安装了JRE /local/java/jre1.7.0_60/bin/java到您的当前路径):

Tell the system that you have JRE installed (update usr/local/java/jre1.7.0_60/bin/java to your current path):

$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_60/bin/java" 1

将新的JRE设置为默认值:

Set the new JRE as default:

$ sudo update-alternatives --set java /usr/local/java/jre1.7.0_60/bin/java

Cassandra可以以root身份启动,而不会显示错误消息。

Now java is installed for root and Cassandra can be started as root without the error message.