Java is a versatile, machine-independent programming language that is used to write a variety of different applications. Unlike most other applications, you can run java applications equally well in Windows, Mac, or Linux, provided you have installed Java Virtual Machine (JVM) in your system. However, if JVM breaks, then none of your java applications run.
One recent impact having a broken JVM launcher was felt by users of Minecraft. A recent update brought new features, but also required Java 16 to set up a server. Those with older version of JVM were greeted with a Java Native Interface (JNI) error.
There are other examples where a malfunctioning JVM launcher caused an application to not work, and it could probably happen again in the future. We have this article prepared, so that you can be prepared when your JVM launcher has an error.
What Causes Java Virtual Machine Launcher Errors
- JVM needs to be updated.
- Default app has not been set to Java.
- Insufficient global maximum heap memory.
- Application needs administrative rights to run.
Fixing Java Virtual Machine Error in Windows
You can somewhat diagnose what is wrong with your JVM and attempt a corresponding fix based upon the type of error message that you see when you JVM does not work.
Reinstall/Update Java
If the error message you see is “Java Virtual Machine Launcher Could Not Find The Main Class,” then Java has been incorrectly installed or Java installation has been corrupted in your machine.
JNI errors can be caused by outdated version of Java.
To fix this, you need to reinstall Java Runtime Environment.
Windows 10
- Launch Settings (Press Win + I), then navigate to Apps.
- Scroll to find Java and select Uninstall.
- Download and install the latest version of Java.
- Restart your computer.
Windows 11
- Launch Settings, navigate to Apps > Apps & features.
- Scroll to find Java.
- Click on the kebab button to its right, then select Uninstall.
- Download and install the latest version of Java.
- Restart the computer.
Increase System Memory for Java
You will get a “Could not create the Java virtual machine” error if Java is trying to use more memory than has been assigned to it.
You can fix this by increasing the amount of memory allotted to Java.
- Press Win + R and type
contro
l to launch the Control Panel. - Navigate to System > Advanced System Properties.
- Click on Environmental Variables, then click New… under System variables.
- On the box next to Variable name, type in
_JAVA_OPTIONS
. - On the box next to Variable value, type in
-Xmx512M
.
Run as Administrator
Sometimes JVM errors can occur because you do not have sufficient user privilege to run the application.
You can fix this by configuring Java to run as administrator.
- Press Win + E to launch Windows Explorer, then navigate to Java installation folder. (Usually located at “
…/Program Files(x86)/Common Files/Oracle/Java/javapath
”) - Find
java.exe
and right-click on it. - Select Properties.
- Switch to Compatibility tab and put a tick mark on Run this program as an administrator.
- Click Apply, then click OK.
Set File Type Association to Java
If your error message is “Unable to access Jar file,” then one of the reasons for this issue is that your jar file association is not set to Java.
Windows 10
- Launch Settings (Press Win + I)
- Navigate to Apps > Default apps.
- Click on Default apps by file type.
- Scroll to find
.jar
from the list of file types. - Click on the currently set default application next to it.
- Click on Java(TM) Platform SE binary.
- Close Default apps setting.
Windows 11
- Press Win + I to launch Settings.
- Navigate to Apps > Default apps.
- Enter
.jar
file type in the box under Set a default for a file type of link type. - Click on the application that is currently selected to open .jar files, then click on Java under Other options.
- Close settings.
Frequently Asked Questions
What is Java Exception Error?
And exception is an unexpected event which occurs during program execution. Java has methods to catch and handle exceptions.
An application that has implemented exception handling methods will create an exception object when it runs into an exception during execution.
The object contains information such as name and description of the exception, as well as the state of the application when the exception was caught.
What is the Maximum Java Heap Size for Windows?
The maximum allowable heap size for Java in Windows is 16 EB (exabyte). For 32 bit of Windows, maximum heap size is 4 GB.
How Do I Install Java on Mac?
Please follow the steps below if you want to install Java on your MacOS:
- Download
jre-8u65-macosx-x64.pkg
from the official site. - Launch the file by double clicking on it.
- Double click the package icon to launch Install Wizard.
- Follow on-screen instructions.
Please note that you need a macbook with Intel processor to install Java. Oracle does not officially support Java on M1/M2 processors yet.