PHP script running a java program

software development

#1

I have a simple java program that generates an image by taking in base images, altering them based on parameters, then combining them. It’s done in a way that I can’t imagine the program needing more than 2 megs of heap. (considering the few base classes that need to be loaded into memory) I can run it fine from the shell. It was initially meant to be executed directly from PHP, but I kept getting an exit value of “127” so I changed it to have the parameters processed (and verified) by the PHP script, then have them sent to a perl script, which executes the java program, and this also runs fine from the command line. I get the following error:

Error occurred during initialization of VM
Could not reserve enough space for code cache

Is there a way around this? Would it work if ran it as a cgi script, or is there some java option that will prevent the JVM from using a large amount of memory? (I’ve read complaints in the Java forums that it requires a gig by default…)


#2

Java isn’t exactly lightweight, but you can try the -XX:ReservedCodeCacheSize=16m option if you’re using the Hotspot vm.

Free unique IP and $67 off with code [color=#CC0000]LMIP67[/color] or use [color=#CC0000]LM97[/color] for $97 off. Click for more promo code discounts


#3

I went as low as 4m with that option, and it’s still not working. Same error. I think I’m going to need to make an equivalent in another language. Ugh.

edit: Anyway, thanks for the help. It took about 2 and 1/2 hours, but I ported it to PHP pretty quickly. In fact, some of the code was actually simpler in PHP. Go figure.


#4

Very cool! A testament to your flexibility as a developer.

BTW, friends of mine tell me that as a Java developer I should really take a look a Ruby. It might be worth you taking a look at it if Java is your “home” language since it’s better supported here.

Free unique IP and $67 off with code [color=#CC0000]LMIP67[/color] or use [color=#CC0000]LM97[/color] for $97 off. Click for more promo code discounts