Most of the time you can fix this problem by uninstalling the Java runtime and then reinstalling it all over again. If you have both 32- and 64-bit applications that need to use Java, then you’ll need to download and install both versions of the Java runtime. Hopefully, this will fix your problem. Sometimes this error can be caused by not having enough system memory allocated to the Java Virtual Machine – or not enough system memory. In this case try the following :
Tap on Windows-Pause to open the System Control Panel applet. You can alternatively open the control panel manual to go there if you prefer it that way.
Click on advanced system settings on the left.
Select environmental variables here.
Click on new under System Variables.
Enter _JAVA_OPTIONS as the variable name.
Enter -Xmx512M as the variable value.
Click ok twice.
This allows up to 512MB to be allocated to the Java virtual machine. You can experiment with different values, if required. That’s it, your Java program should now be able to execute properly.
For those interested, Java -Xmx/s is the configuration parameter that control the amount of memory Java uses.
Xmx sets the maximum heap memory size
Xms sets the minimum heap memory size