Putting JVM arguments in a file to be selected at runtime

I am creating a jar of my current application, for which it is necessary to install several JVM arguments.

Is there a way to set these JVM arguments in a file and not on the command line?

I did some hunting, and it looks like I could do something with the java.properties file, possibly by installing java-args, but I cannot find a format link for this.

Am I barking the wrong tree?

Is this possible, and if so, how?

If not, is there another way to specify JVM arguments?

+3
source share
3 answers

Of course, you could write a script package to execute the JVM. The script package could look into the file and call the appropriate parameters. It depends on the OS.

+5
source

Very often for a shell jar / bash script to configure arguments and environment variables before starting the JVM

for example, on * nix systems you can 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 
+1
source

If you are using a jar file, you can customize the manifest file and provide some information (main class, etc.) in this file.

You can also link to other jar files that will be used by your main jar file. For instance. third parties that you do not want to include in your company’s jar file.

Also the other guys are right - set up the batch file / script.

0
source

All Articles