views:

421

answers:

1

Hey everyone,

I have a jar file that I would like to execute using PHP, but when I run the script all I get is the following error: Could not reserve enough space for object heap. I have done some searching and it seems as though I am getting this because the command isn't being executed in a login shell. If this is the case how do I do so? I have tried both shell_exec() and exec() and both produce the same error.

Thanks for the help!

+1  A: 

Using exec() would normally work properly; however, in your case it looks like Java is unable to allocate enough memory to start (hence the error message). If you're running in a virtual machine with limited RAM and no swap space, you'll find it all but impossible to run even the simplest java programs.

The first step is to see if java runs at all on your machine. Try to just run

java -version

If that fails with the same error, you'll have to increase the amount of memory available somehow (eg, buying a plan with more memory or swap space). If you can't, you might be able to get by if you limit the maximum heap size with -Xmx16m (sets the maximum heap size to 16 megabytes) or even less, but in that case your jar file may not have enough memory to run!

Daniel G