How do I fix a failed to create Java Virtual Machine?

How do I fix a failed to create Java Virtual Machine?

How to fix a failed to create Java Virtual Machine Set up a new system variable for Java. Open Run with the Windows key + R keyboard shortcut. Select the Run as administrator option for Java. Open Cortana with the Windows key + S keyboard shortcut. Reinstall Java.