I have the most recent version of Java installed and it works fine in Eclipse and with other programs.
Could not create the Java virtual machine
After ensuring that the _Java_Options environment variable sets an adequate heap I explored the BlueJ program folder. I see that in bin it has its own javaw.exe. When I try to run this I get the same error.
How can I fix this?
I’m on Windows 10 64-bit.
This IDE claims to have its own JDK and to be ready to run out of the box:
On Windows, BlueJ comes bundled with a Java Development Kit, JDK, so only a single download is needed.Download the Duke/Coursera specific version (choose Save instead of Run) Double-click the downloaded install file and follow the wizard to install it in your preferred location By default, the installer will place a shortcut to BlueJ on your desktop
I finally had the good sense to try run the .exe from the command line and pipe the results to a text file:
C:Program Files (x86)BlueJ>BlueJ.exe > tmp.txt
The contents of the text file are:
Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap
So it seems that it doesn’t have enough memory, but this is strange because I immediately checked Resource Monitor and my RAM usage is only 2.7 GB out of 16 GB.
To make matters more strange I just changed the
_JAVA_OPTIONS heap size to 1GB and reran the exact same command. The result was the precise same error message… it’s still trying to allocate 2GB even though I scaled back the heap to 1GB…
I also set
SET JAVA_OPTS=”-Xms256m -Xmx512m”
but I still get the same result.
At long last I got this working.
The trick was to set the initial — not maximum and not initial and maximum — heap size in
_JAVA_OPTIONS to a very small value, which I believe is because BlueJ insists on using 32-bit Java even though 64-bit is available:
Note that the same setting in
JAVA_OPTS did no good.
If you have a deeper understanding of why this is and would like to submit a better version of this answer then please do so and I’ll mark your answer as the solution.