Fix Could Not Open jvm.cfg in Java

Sometimes, we think everything is working as expected, but some issues are behind the scenes. Today, we will discuss a similar situation and determine possible solutions.
the Could Not Open jvm.cfg
Error in Java
This error occurred when we updated our machine to Windows 10 but later reverted to Windows 8 for a few reasons. All the applications worked fine, but we had an issue running Java Programs.
Whenever we try to compile the Java program, it compiles successfully, but as soon as we run this, it gives an error as follows.
Example Code (We are using JDK 8
):
C:\>javac test.java
C:\>java test
Error: could not open C:\Program Files\Java\jre8\lib\amd64\jvm.cfg
Fix the Could Not Open jvm.cfg
Error in Java
There are a few possible solutions for this. Let’s have a look at each of them below.
Solution 1: Remove .exe
Files From the System32
Folder
Go to the folder System32
, which resides in the C:\Windows
location.
C:\Windows\System32
Remove the java.exe
, javaws.exe
, and javaw.exe
from the folder. The error is gone; now, run the program again to get your desired results.
If this solution does not work for you even after deleting the .exe
files, then go for the following solution.
Solution 2: Make Sure the Java PATH
Is Correct
The other reason can be having an incorrect Java Path. So, write the following line at the start of the PATH
.
%JAVA_HOME%\bin
The error must be resolved. If the error persists, then we can try the following solution.
Solution 3: Delete Oracle Directory Executable Files
Go to the following directory.
C:\Program Files\Common Files\Oracle
Start looking for the executable files related to Java. Remove them if you find them.
Now, the error is resolved. If you are still reading this article, the error still annoys you.
So, go for the final solution, which is given below.
Solution 4: Uninstall Java and Reinstall It
The final solution is to uninstall Java. Make sure that you remove the references to it from the Registry
and then reinstall it.
This trick must work, and you must eliminate the error now.
Related Article - Java Error
- Fix the Error: Failed to Create the Java Virtual Machine
- Fix the Missing Server JVM Error in Java
- Fix the 'No Java Virtual Machine Was Found' Error in Eclipse
- Fix the Error: Failed to Create the Java Virtual Machine
- Javax.Net.SSL.SSLHandShakeException: Remote Host Closed Connection During Handshake
- Java.Lang.VerifyError: Bad Type on Operand Stack