Hack-R
Hack-R

Reputation: 23216

Java works fine in Windows but BlueJ IDE's Java fails

I have the most recent version of Java installed and it works fine in Eclipse and with other programs.

A Duke University online course wants me to download and run their flavor of BlueJ for Windows. I installed it, but it can't launch. It says:

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:

Windows

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

Update:

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.

Upvotes: 4

Views: 775

Answers (3)

Abitatha Roy
Abitatha Roy

Reputation: 81

Try to reinstall BlueJ. This time, change the install directory from (C:\Program Files(x86)) to (C:\Program Files). It should work.

Upvotes: 0

Hack-R
Hack-R

Reputation: 23216

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:

SET _JAVA_OPTIONS="-Xms256m"

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.

Upvotes: 1

Zia
Zia

Reputation: 1011

Please check your firewall setting and if there is any special character used in project name/path then remove it and keep it without special characters.

You may refer the below link may be it will solve your problem,

http://www.bluej.org/faq.html#faq_What_should_I_do_about_this_error___Bluej_was_unable_to_create_a_virtual_machine__VM__to_execute_projects__

https://ask.fedoraproject.org/en/question/43029/bluej-not-working/

Upvotes: 0

Related Questions