Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add jvm parameters for a runnable jar?

For the runnable jar that i am creating. it requires xmx1024 as JVM argument. How can i do this ? Or is there any alternative ?

like image 298
Arun Abraham Avatar asked Dec 09 '12 12:12

Arun Abraham


2 Answers

You can provide a startup script for each and every platform the program is intended to run on. For example on Linux you can have program.sh

java -mx1024 -jar lib/artifact.jar arg1 arg2

Obviously you have to tell the user that the program is intended to be run from the startup script, because if they try to manually start the jar it will fail.

You can even check in your program if the VM has been started with the required arguments and fail soon if not. Refer to this answer.

like image 171
Raffaele Avatar answered Oct 17 '22 09:10

Raffaele


There are tools like Capsule that can bundle an executable jar with JVM args and even platform-specific startup scripts.

like image 36
jiggy Avatar answered Oct 17 '22 10:10

jiggy