4

I have set my environment variables up. Window 7 - 32 bit

C:\Users\user>java -version
Error: could not open `E:\lib\i386\jvm.cfg'

C:\Users\user>echo %JRE_HOME%
C:\Program Files\Java\jre7\bin

C:\Users\user>echo %PATH%
C:\Program Files\PC Connectivity Solution\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\jdk1.6.0_22/bin;C:\Program Files\Java\jre7\bin/bin;C:\Ruby193\bin;C:\Ruby187\bin

C:\Users\user>java -version
Error: could not open `E:\lib\i386\jvm.cfg'

I checked on E: there is nothing on the location. I have JRE7 and jdk1.6.0_22.

Could you please give me solution for this?

I tried to use this solution, Not able to properly set up the path of java in Windows 7 , 64 bit however, while clicking on JAVA present on control panel it is giving me same error message. [ Error: could not open `E:\lib\i386\jvm.cfg']

Community
  • 1
  • 1
Yougandhara
  • 329
  • 1
  • 4
  • 15
  • Probably, you have %JAVA_HOME% variable set – dpassy Feb 23 '15 at 20:46
  • http://stackoverflow.com/questions/9051103/java-path-error-of-jvm-cfg – Andremoniy Feb 23 '15 at 20:50
  • I have set JAVA_HOME too C:\Users\user>echo %JAVA_HOME% ---> C:\Program Files\jdk1.6.0_22 – Yougandhara Feb 23 '15 at 20:50
  • Did you try Andermonly's comment? – dpassy Feb 23 '15 at 20:53
  • Yes, I did! I reinstall JRE and checked that the jvm.cfg file is present in the specified location. All paths are correct! Still on opening new cmd prompt I am getting the same error. – Yougandhara Feb 23 '15 at 20:56
  • It is very unlikely that JAVA_HOME is the source of the problem.. http://stackoverflow.com/questions/2025290/what-is-java-home-how-does-jvm-will-find-the-javac-path-stored-in-java-home – Adam Feb 23 '15 at 21:00
  • Have you checked that you don't have a `doskey` macro set for `java`? – RealSkeptic Feb 23 '15 at 21:11
  • I don't suppose I understood your question? how to check that? could that be a cause for this problem? – Yougandhara Feb 23 '15 at 21:16
  • Well, `doskey` is a command used to set command-line macros. So you can set shortcuts for long commands and other stuff. If you have such a shortcut set for `java`, it may be running outside of your path. try `doskey /macros` and see if there is anything `java` in there. – RealSkeptic Feb 23 '15 at 21:21
  • Thanks for the help. Re- Installation of Java and setting the paths from starts helped. – Yougandhara Feb 23 '15 at 21:51

4 Answers4

5

When you install a JRE, the installer writes a special java.exe in the Windows system directory (ex . C:/winnt/system32/java.exe). This java.exe will look in the registry to get the location of the current JavaHome.

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion]  (64 bits or 32 bits only)
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\CurrentVersion] (32 bits installed on OS 64 bits)

and then get the path of the JRE for the version marked as current.

For a 32 bits JRE installed on a Windows 64 bits installation :

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\CurrentVersion] -->  1.8

and then

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\1.8\JavaHome] --> C:\Program Files (x86)\Java\jre1.8.0_31

So verify the values in the registry and clean up you PATH because you don't need it to launch java.exe from the command prompt by typing only java.exe.

If your setup is correct, you will be able to override the default JRE without modifying your PATH :

> java -version:"1.6" MyClass  (force the jre 1.6 installed to be used)

The JAVA_HOME and JRE_HOME environment variable are not used by the JRE installed in the "Program Files" with the installer, they are used by convention by IDE, tools or application server.

RealHowTo
  • 34,977
  • 11
  • 70
  • 85
  • Please note that the JRE `-version:` parameter is planned to be removed in JDK9, http://openjdk.java.net/jeps/231 – RealHowTo Feb 13 '18 at 17:58
0

Why do you have a JDK 1.6 and a JRE 7?

And your Java environment variables are set wrong. The jdk and jre paths have a backward slash before the bin, your jre has \bin\bin

edit I am referring to your path variable here

Please use either jdk 1.7 or jdk 1.6. That choice depends on development you are doing. The jdk contains a Jre so you do not need to download both.

Note that if you are not confident about manually setting the path, you can rely on the the installer that does all the required steps for you.

baddy
  • 47
  • 4
Droidekas
  • 3,464
  • 2
  • 26
  • 40
  • I have updated the path to "C:\Program Files\PC Connectivity Solution\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;%JAVA_HOME%/bin;%JRE_HOME%/bin;" still getting the same issue. Having jdk 1.6 and a Jre 7 is that a problem? should I update/uninstall any of that? – Yougandhara Feb 23 '15 at 21:04
  • what are you using Java for? is it Java based development? or browsing or anything else? – Droidekas Feb 23 '15 at 21:17
  • in all cases, your path should contain only one Java. you can make jre_home point to the jdk 1.6 Jre folder. – Droidekas Feb 23 '15 at 21:18
  • 1
    please change the `/` to `\\` in your path variable for both the Java paths – Droidekas Feb 23 '15 at 21:30
  • Still I am getting 'Error: could not open `E:\lib\i386\jvm.cfg' :( – Yougandhara Feb 23 '15 at 21:35
  • 1
    are you sure you have jdk 1.6 32 bit? and I really suggest Uninstall in and reinstalling Java to fix this solution http://stackoverflow.com/a/18664400/3396197 – Droidekas Feb 23 '15 at 21:40
  • Yes I do have jdk 1.6 32 bit. Thanks for the post. it helped :):) – Yougandhara Feb 23 '15 at 21:49
0

Type

echo %PATH%

and check from which location your java.exe is invoked. Path could be overriden by old java installation.

Piotr Zych
  • 483
  • 4
  • 19
0

When Java is installed on Windows 7 using the installer download, a copy of java.exe is installed by default in C:\Windows\System32 and a link to java.exe is created in C:\ProgramData\Oracle\Java\javapath which is added to your Path environment variable.

When you run java -version it is useful to ask what java executable does that invoke and where is it located? Your issue may be simplified and possibly solved by renaming or removing conflicting Java executables from the System32 folder and from other locations in your personal Path and the system Path in which they may also be installed.

baddy
  • 47
  • 4
  • That is the problem..I checked the location its showing in cmd "Error: could not open `E:\lib\i386\jvm.cfg'" However, there is no lib folder or anything present in E driver. However, why is it showing that location is the mystery. What am I missing.. – Yougandhara Feb 23 '15 at 21:21
  • Try completely reinstalling Java preferably after removing all old installations in all locations and all Path components referencing them including those in your personal Path and the system Path. –  Feb 23 '15 at 22:10