且构网

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

当我安装 Java 7 时,cassandra 2 抱怨 Java 7

更新时间:2023-01-15 10:51:20

我在尝试启动 Cassandra 时收到相同的错误消息.但是我注意到只有在以 root 身份启动 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(更新 usr/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

现在已经为 root 安装了 java,并且 Cassandra 可以作为 root 启动而不会出现错误消息.

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