Executing java program from php

When trying to execute a simple Java application from the command line everything works fine. When trying to do it via PHP it fails with this error: “Error occurred during initialization of VM. Could not reserve enough space for code cache”.

The code is:

$output = shell_exec(‘cd thumb; java ThumbnailTest card.scratch’);

How do you go about doing something like that?