Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read system properties from file specified as java executable argument

By launching java with the -D option you can set System.properties.

Is there a way to specify a properties file as an option for java, which in turn read them as System.properties?

E.g.

java -Dfile ./alotof.properties

I'm building a webapp deployed in JBoss. The jboss xml configuration files accepts system properties as inline config {my.property}, which reads from the command line argument but this gets unruly as the number of properties grow.

like image 529
Elijah Avatar asked Jun 26 '26 14:06

Elijah


1 Answers

You can read the properties file in bash (in run.sh file), parse properties and create the proper config line for JVM.

Here you can find 2 articles that can help you:

  • Reading Java-style Properties Files with Shell (permalink)
  • Reading java.properties file from bash
like image 80
Lukasz Stelmach Avatar answered Jun 28 '26 03:06

Lukasz Stelmach



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!