Putting JVM arguments in a file to be picked up at runtime

Putting JVM arguments in a file to be picked up at runtime



I'm building a jar of my current application, which required several JVM arguments to be set.



Is there a way of setting these JVM arguments in a file rather than on the command line?



I've done some hunting and it looks like I might be able to do something witha java.properties file, possibly by setting a java-args, but I can't find any reference to the format for doing this.



Am I barking up the wrong tree?



Is this possible and if so how?



If not is there some other way to specify the JVM arguments?




3 Answers
3



You could of course write a batch script to execute the JVM. The batch script could look into the file and call with the appropriate parameters. This would be OS dependent though.



It's very common to wrap jar file shell/bash script to setup arguments and enviroment variables before starting the JVM



for example on *nix systems you could do something like this


#!/bin/sh
CLASSPATH=foo.jar:bar.jar
JVMARGS=-some_arg
MYAPP_ARGS=-some_args -for -my -app

java $JVMARGS -classpath $CLASSPATH com.my.domain.myapp $MYAPP_ARGS



If you are using a jar file you can setup a manifest file and supply some information (main class etc) in that file.



You can also reference other jar files to be used by your main jar file. E.g. thirdparty jars that you don't want to include in your company jar file.



Aside from that the other guys are right - setup a batch file/script.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ