Skip to content

Fix: Error occurred during initialization of VM

  • by
  • 3 min read

Java is one of the most popular programming languages on the planet. Despite being launched way back in 1996, it still is used on several devices across the world. It’s also rather easy to learn and code with, but that’s not to say it doesn’t come with its own challenges that a developer needs to tackle. 

In this article, we’re talking about the “error occurred during initialisation of VM” issue in Java, its causes and what you can do to fix the problem.


What causes this error?

There are a number of reasons why you might run into this error. Some of the more popular ones include:

  • There isn’t enough memory allocated for the VM
  • Incorrect VM arguements
  • Incorrect JVM version.

Also read: How to fix Javascript error: ipython is not defined?


How to fix this?

Here are three fixes you can try out. 

Check the command line arguements

The first thing you should do is check the command line arguemnets you’re using to specify how many resources the VM should get. Usually running a command with a specific memory and heap size is recommened as given below. 

java -Xms256m -Xmx512M 

The aforementioned command will restrain the heap size that the VM will try to reserve at boot. You might need to change the values in the aforementioned command to find the right pair that works for you. 

Also read: How to fix Excel error: Object variable or with block not set?


Check your JRE version

IF you’re using 32-biut JRE, you can’t use more than 1.5GB of RAM on your VM. If you want to use more RAM you’re going to have to upgrade to the 64-bit installation. Check your JRE version and make sure your memory allocation is in-line with the JRE version you’re running. 

Top 7 IDEs and Text Editors to code Python, Java, C++, HTML and more

You can check your JRE version using the following command.

java --version

Check Java options

Your VM initialisation settings need to be in line with your currently set Java options. You can refer to your current Java options using the following command.

echo $_JAVA_OPTIONS

If the Java options don’t line up with the VM arguments, you’re going to see this error or similar ones based on the disparity between the two configurations. This mostly refers to the memory requirements you want, so you might have to either update your JRE version or downgrade your machine’s memory requirements. 

Also read: What is the unexpected reserved word await error in Javascript?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>