[Solved] Error Could Not Open jvm.cfg

If you are facing the error could not open jvm.cfg then do not worry. It has a simple but weird fix.
I faced the same issue when I tried to run a simple java program. I was using the jdk8. The interesting fact was that the program compiled successfully. But when I was executing the java program then it was giving Error: could not open C:\Program Files\Java\jre8\lib\amd64\jvm.cfg.

Read Also: Could not find or load main class

In short, below is the scenario

C:\JavaHungry>javac SimpleProgram.java
C:\JavaHungry>java SimpleProgram
Error: could not open C:\Program Files\Java\jre8\lib\amd64\jvm.cfg

Let's find out the solution/fix.

Fixed- Error: could not open C:\Program Files\Java\jre8\lib\amd64\jvm.cfg

1. Go to below folder

C:\Windows\System32

2. Remove below files from this folder
    java.exe,
    javaw.exe, 
    javaws.exe 

3. Run the program again, voila, the error is resolved.

If the above problem does not resolve even after deleting the .exe files, then, try this

2. PATH is not correct

1. Put below the line at the beginning of the PATH.

%JAVA_HOME%\bin
   
voila, the error is resolved.

If the above problem still persists, then

3. Remove Oracle directory executable files

Check the below directory

C:\Program Files\Common Files\Oracle

and remove the java related executables.

voila, the error is resolved.

If you are reading this line it means, you are still facing this annoying error. So the last trick is

4. Uninstall Java, Remove references to it from Registry and Reinstall it

That should do it.

That's all for today, please let me know in comments which of the above 4 methods solved the error: Could not open C:\Program Files\Java\jre8\lib\amd64\jvm.cfg.

About The Author

Subham Mittal has worked in Oracle for 3 years .
For more java articles ,Click here to Subscribe JavaHungry