Visual Studio does not initiate Java Virtual Machine

Hello,
I’ve been toying with the Android SDK in Visual Studio 2012 and for some reason, compiling my code tends to cause the following three errors:

1.()Error: Could not create the Java Virtual Machine.
2.()Error: A fatal exception has occured. Program will exit.
3.(AP1)Error while running Android tool: dx.bat.

This frequently happens after making and correcting a code error and restarting my computer, Visual Studio, or the Android Virtual Device doesn’t change anything.

What do I do?

Thanks in advance!

Hello,

this is an unknown bug. Could you please provide exact steps on how to reproduce that error. Does it reproduces for any project or a particular one? If it is a particular project could you give it to us so we can fix the problem.
Also what VS do you have?

Thanks in advance.

Hello,

this is an unknown bug. Could you please provide exact steps on how to reproduce that error. Does it reproduces for any project or a particular one? If it is a particular project could you give it to us so we can fix the problem.
Also what VS do you have?

Thanks in advance.

Hi viktoriad,

I’ll try to answer your questions below.

  1. I’m not really sure what part of it caused the error, but I did the following:

  2. Create a new Android application, the standard template.

  3. Do some changes to the code, each one including the example provided on the
    wiki and the web tutorials related to making a toast appear when the button is
    pressed.

  4. Make an error sooner or later.

  5. Fix the error.

After I do all of the above I eventually find myself unable to compile the code, with VS throwing out the above error set.

  1. It happens for any project, though sometimes if I try running the last working build it works properly. Not always though.

  2. I’ll write down the information, hopefully it’s what you’re looking for:

Microsoft Visual Studio 2012 Shell (Integrated)
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.5.50709
Installed products: RemObjects Everwood 4.0.33.371, RemObjects Oxygene 5.2.37.1071.

Is that what you needed?

Hello,

Could you please upgrade you Oxygene to the latest (Sep12 release or latest betta).

Hope that helps.

I’ll try, though I’ve heard that it may in fact be related to Java itself.

Also, your product version check is saying “All your projects are up to date!” despite the fact that it’s not yet true. You might want to see if it’s working properly.

Edit: Well, updating didn’t help.

Hello,

Sorry for the delay. We tried to reproduce your problem on several machines but couldn’t.

What version did you try? I checked and seems the working version is any latest betta. Also could you please set Detailed output for VS (Tools => Options => Projects and Solutions => Build and run => Select Detailed in the MSBuild project output verbosity). Next time when you experiense the problem please send us the output log so we can examine what exactly happens.

Thanks is advance.

nevenpjr said: Also, your product version check is saying "All your projects are up to date!" despite the fact that it's not yet true. You might want to see if it's working properly.
my apologies, it looks like the info was not updated for the freshly released September build, yet. fixed now.

Well, I tried again to get the logs. They’re attached in a .txt file.

Also, I tried to tell you this earlier today, but it didn’t pass for some reason… I’m using 5.2.39.1091.

Edit: Okay… that was strange, but explained why my previous reply failed. The website seems to want me to click “Post Comment” twice.

Sorry, but I don’t see attachment in your post.

Sorry, but I don't see attachment in your post.

Uhhhhh… why does it keep erasing my posts and attachments at will!?

Oh well, attaching it again. Probably missed some hidden step like the one mentioned in my previous post…

Edit: Yeah, whatever wanted me to TRY posting twice also wanted me to reattach it before the second attempt. Interesting.

Re-edit: I’m trying to figure out a solution myself, but I need to know where the .ini files for the JVM are located. Based on a similar issue I’ve been reading about (true now, that’s an Eclipse issue, but it may be the same thing), Java may be trying to allocate more memory to the JVM than it can. (2 GB RAM, but… if the settings are wrong, it could be a problem)

Hello,

The error from the log definitelly sounds like “Out of memory” error. We are using Xmx1024M by default when running java so probably it is the problem in your case. Unfortunatelly it is not possible to changes that default value to e.g.512 now. I have logged an issue for furthe review (bugs://58635).

Best regards,

Yeah, I read about it on stackoverflow.com. From what I understand, it tries to make sure there’s Xmx1024M + XXMaxPermSize (which appears to be 512 MB by default) RAM available, and cutting my memory usage to 1/4 of my capacity is a bit tricky. But hopefully I’ll get an upgrade soon.

Thanks for trying, anyway!

Interesting website update.

Anyway, I’ve doubled my memory to 4 GB and it still reports the same issue. Strangely enough, it did seem to work every once in a while back before I made the original post, but the crashing was the rule rather than the exception.

Which means there’s another problem, or something’s gone wrong since then. But according to Windows’ resource monitor, I’m only using 50% of my RAM.

Hi,

I am having the same problem.

Version:

Microsoft Visual Studio 2012 Shell (Integrated)
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.5.50709

RemObjects Oxygene 5.2.40.1081
RemObjects Oxygene

???

thanks
Willian

error :
Run: “C:\Program Files (x86)\Java\jre7\bin\java.exe” -Xmx1024M -jar “C:\Users\willian\AppData\Local\Android\android-sdk\platform-tools\lib\dx.jar” --dex --verbose --output=“C:\Users\willian\documents\visual studio 2012\Projects\org.me.androidapplication1\org.me.androidapplication1\obj\Debug\classes.dex” --positions=lines “C:\Users\willian\documents\visual studio 2012\Projects\org.me.androidapplication1\org.me.androidapplication1\obj\Debug\org.me.androidapplication1.jar”

	  Error occurred during initialization of VM
	  Could not reserve enough space for object heap

C:\Program Files (x86)\MSBuild\RemObjects Software\Oxygene\RemObjects.Oxygene.Android.targets(76,3): error : Error: Could not create the Java Virtual Machine.

C:\Program Files (x86)\MSBuild\RemObjects Software\Oxygene\RemObjects.Oxygene.Android.targets(76,3): error : Error: A fatal exception has occurred. Program will exit.

Hi,

I also unable to reproduce this problem here.

The possible causes of such error could be:

  1. Few versions of Java are installed together, just try to uninstall all Java installations from your machine and install the latest Java JDK for your OS, make sure you install the x64 version if you are using a 64bit OS.
    2)The heap size allocated for java virtual machine is not big enough. Try to increase the maximum heap size. For this you can pass some parameters in command line to java. The parameters may be:
    -Xms (initial Java heap size)
    -Xmx (maximum Java heap size)
    -Xss (java thread stack size)

Hope this helps.

I think it’s becoming clear that this is not really an Oxygene issue per se, but a general issue with the Java VM on the affected systems. IMHO we’ll need to check with Java support on this.

After updating my JDK from 7 to 9, I managed to get a successful compile, however the program crashed due to a previously undetected error in the code.

Upon switching to a more functional version (the standard template, to be exact), I first had the same issue as before, but after restarting my computer, only the 3rd error from my original post remained.

I haven’t tried the second option ekaterina mentioned, but that’s because I don’t quite understand how to do it.

Attaching another log just in case.

Edit: Well that’s nice. I didn’t have to try twice to make it work. Website update, I presume?

Most possible these errors are connected with your personal sysytem settings. Try to play with memory size, as I mentioned above.

  1. To set up the heap size of java, pass parameters in command line to java.
-Xms<> - to set initial Java heap size
-Xmx<> - to set maximum Java heap size
-Xss<> - to set Java thread stack size

For example,

java -Xms256m -Xmx512m Application
  1. Another option is to decrease max heap size for device in the

android-sdk-windows\platform-tools\dx.bat

Tyr to change it to 512M instead of 1024M.

set defaultXmx=-Xmx512M

Yeah, but I don’t understand what command line do you mean. Command Prompt, or a program (or part of one)?

Trying option 2 as I write this.

Edit: No luck, sadly. Waiting for explanation of option 1.

Sorry, I was wrong suggesting to tune Java options, it’s not possible in this case, because we are using definite values (Xmx1024M) when running java. Also we cannot simply change the allocated memory because it can cause problems to other users.
This is not Oxygene, but Java issue.