Running Java gives “Error: could not open `C:Program FilesJavajre6libamd64jvm.cfg’”

Tags: ,



After years of working OK, I’m suddenly getting this message when trying to start the JVM:

Error: could not open `C:Program FilesJavajre6libamd64jvm.cfg'

I tried uninstalling, and got a message saying a DLL was missing (unspecified) Tried re-installing, all to no avail.

At the same time, when trying to start Scala I get:

Javajdk1.6.0_25binjava.exe was unexpected at this time.

Checked %JAVA_HOME% and %path% – both OK

Can anyone help?

Answer

Might be a slightly different cause, but that second issue occurs for me in scala 2.9.0.1 on Win7 (x64), though scala-2.9.1.final has already resolved this issue mentioned here:

Javajdk1.6.0_25binjava.exe was unexpected at this time.

My %JAVA_HOME% set to a path like this: c:program files(x86)Javajdk...

Note the space and the parentheses.

If you change line 24 in %SCALA_HOME%binscala.bat from:

if exist "%JAVA_HOME%binjava.exe" set _JAVACMD=%JAVA_HOME%binjava.exe

to

if exist "%JAVA_HOME%binjava.exe" set "_JAVACMD=%JAVA_HOME%binjava.exe"

It works fine. Note the quotes around the set command parameters, this will properly enclose any spaces and ‘special’ characters (eg: spaces and parentheses) in the variable’s value.

Hope this helps someone else searching for an answer.



Source: stackoverflow