How to add jvm parameters for a runnable jar?
Asked Answered
A

2

5

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

Abutment answered 9/12, 2012 at 12:25 Comment(2)
Do you want to run your code from eclipse with that JVM argument, or do you want to make sure that whoever runs your code will use that JVM argument?Synod
In eclipse i can specify the JVM argument, so its fine. But i want to give this runnable jar to another person. Well, can you explain me how i can specify the jvm argument for running the runnable jar.Abutment
L
6

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.

Laclos answered 9/12, 2012 at 12:31 Comment(0)
D
1

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

Diesis answered 24/8, 2014 at 3:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.