简体   繁体   English

JAVA_HOME在Windows 8上没有设置

[英]JAVA_HOME get unset on Windows 8

I'm working on Windows 8 using oracle Java 7 and JRuby (from TorqueBox 2.2.0). 我正在使用oracle Java 7和JRuby(来自TorqueBox 2.2.0)开发Windows 8。 In the terminal the JAVA_HOME environment variable has some weird behaviors ... 在终端中,JAVA_HOME环境变量有一些奇怪的行为......

If I enter "set" I get what I'm expecting: 如果我输入“set”,我会得到我所期待的:

JAVA_HOME=C:\Program Files (x86)\Java\jre7

I can for instance run bundle exec rspec and it will work Then I run 我可以例如运行bundle exec rspec,它会工作然后我运行

set COVERAGE=true

and run the same command again and I will get 并再次运行相同的命令,我会得到

Cannot locate Java installation, specified by JAVA_HOME:

I can enter this several time, always the same result. 我可以输入这几次,总是一样的结果。 But mysteriously I can sometime do something like 但神秘的是我有时会做类似的事情

jruby -S bundle exec spec

and it will sometimes work ... sometimes not ... 它有时会工作......有时候不...

It's totally random and unpredictable ... it's a real pain ! 这完全是随机的,不可预测的......真是太痛苦了! Anyone any idea ? 有人有什么想法? From my point of view it just looks like an old Windows bug because everything was fine on Windows 7 从我的观点来看,它看起来像一个旧的Windows bug,因为Windows 7上的一切都很好

Already tested: 已经测试:

  • installing the x64 Java instead of the x86 安装x64 Java而不是x86
  • have a trailing / at the end of the path 尾随/在路径的末尾

It may have to do with the whitespace inside of the path. 它可能与路径内的空白有关。 You've defined it properly, but some scripts may use it like this: 您已正确定义它,但某些脚本可能会像这样使用它:

%JAVA_HOME%\bin\java ...

which will fail. 哪个会失败。 In cases like this, one always must remember the quote marks: 在这种情况下,总是必须记住引号:

"%JAVA_HOME%\bin\java" ...

Except that you say the behaviour is random... Anyway, try moving the installation to a folder without whitespace in the name, see what it does. 除非您说行为是随机的...无论如何,尝试将安装移动到名称中没有空格的文件夹,看看它的作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM