java 找不到logstash的java安装错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30427355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:06:32  来源:igfitidea点击:

Cannot locate java installation error for logstash

javapathlogstashjava-home

提问by Asma Zinneera Jabir

I downloaded Logstash-1.5.0 on Windows 8.1 and tried to run it in the command prompt.

我在 Windows 8.1 上下载了 Logstash-1.5.0 并尝试在命令提示符下运行它。

First I checked the java version. Then changed the directory to logstash-1.5.0/binthen entered the command logstash -e 'input { stdin { } } output { elasticsearch { host => localhost } stdout { } }'it gave the following error:

首先我检查了java版本。然后将目录更改为logstash-1.5.0/bin然后输入命令logstash -e 'input { stdin { } } output { elasticsearch { host => localhost } stdout { } }'它给出了以下错误:

Cannot locate java installation, specified by JAVA_HOME

找不到 Java 安装,由 JAVA_HOME 指定

The Logstash folder is on C: and the version of Java is 1.7.0_25. I've set the JAVA_HOME environmental variables to the jdk/bin directory, but still it doesn't work.

Logstash 文件夹在 C: 上,Java 版本为 1.7.0_25。我已经将 JAVA_HOME 环境变量设置为jdk/bin 目录,但仍然不起作用。

I'm new to Logstash. Can somebody tell me in detail why this happens and help me fix it?

我是 Logstash 的新手。有人可以详细告诉我为什么会发生这种情况并帮助我解决吗?

回答by Razib

Set the JAVA_HOMEand PATHenvironmental variables like this:

设置JAVA_HOMEPATH这样的环境变量:

JAVA_HOME = C:\Program Files\Java\jdk1.7.0_25 
PATH = C:\Program Files\Java\jdk1.7.0_25\bin

回答by Tomá? Fejfar

In my case the problem was that I set the JAVA_HOMEvariable with a space in the end:

就我而言,问题是我最后JAVA_HOME用空格设置了变量:

"set JAVA_HOME=c:\Programs\Java " 

instead of

代替

"set JAVA_HOME=c:\Programs\Java"

And logstash couldn't figure that out :) Removing the space fixed the issue.

而 logstash 无法弄清楚:) 删除空间解决了这个问题。

回答by Rene M.

On Windows when you change environment over the system settings, you have to close and reopen the command shell, before the changes take effect.

在 Windows 上,当您通过系统设置更改环境时,您必须在更改生效之前关闭并重新打开命令外壳。

Step by step:

一步步:

  1. Locate your java JRE installation directory you want to use. For example: "C:\Program Files\Java\jre7"
  2. Open start menu right click computer and select settings. In System settings window on right side click on "Extended Systemsettings".
  3. On Tab extended select environment variables, add your JAVA_HOMEvariable to your path and hit OK.
  4. Open command shell and check environment by entering "set" and hit enter. Look if JAVA_HOMEis set.
  1. 找到您要使用的 java JRE 安装目录。例如:“C:\Program Files\Java\jre7”
  2. 打开开始菜单右键单击计算机并选择设置。在右侧的系统设置窗口中,单击“扩展系统设置”。
  3. 在选项卡扩展选择环境变量上,将您的JAVA_HOME变量添加到您的路径并点击确定。
  4. 通过输入“set”打开命令外壳并检查环境并按回车键。看是否JAVA_HOME设置。

If your JAVA_HOMEis now correctly set, logstash should work.

如果您JAVA_HOME现在正确设置,logstash 应该可以工作。