简体   繁体   中英

JAVA_HOME get unset on Windows 8

I'm working on Windows 8 using oracle Java 7 and JRuby (from TorqueBox 2.2.0). In the terminal the JAVA_HOME environment variable has some weird behaviors ...

If I enter "set" I get what I'm expecting:

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

I can for instance run bundle exec rspec and it will work Then I run

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

Already tested:

  • installing the x64 Java instead of the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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