Arun Abraham
Arun Abraham

Reputation: 4037

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 ?

Upvotes: 5

Views: 12317

Answers (2)

jiggy
jiggy

Reputation: 3826

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

Upvotes: 1

Raffaele
Raffaele

Reputation: 20885

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.

Upvotes: 6

Related Questions