Re: Set java system properties based from properties file instead of command line?
Joe Pluta <joepluta-Kokj9vFzZubAKuVPhbf8BAC/[email protected]>
| Newsgroups | gmane.comp.lang.as400.java |
|---|---|
| Message-ID | <[email protected]> |
Yes, but you can't specify the file on the command line. Well, you sort
of can, but in a minute.
First, you could do this somewhere in the bowels of your application, in
one of your base classes:
java.io.InputStream props = loader.getResourceAsStream("myProperties.txt");
System.getProperties().load(props);
But that's fraught with peril, as you may overlay system properties.
And in fact, once you've gotten to the point where you have a base class
that you can modify, you could just write your own small routine to
parse an .ini file and do the system.setProperty.
I'm guessing, though, that you want to just be able to specify a
properties file on the command line and have the JVM parse it for you.
And that, sadly, is not an option AFAIK.
On 3/14/2019 3:24 PM, David Gibbs via JAVA400-L wrote:
> Folks:
>
> Does anyone know if there is a way to invoke Java code (on the i or
> not) so that system properties are loaded from a property file instead
> of the command line?
>
> What I want to do is avoid using -Dproperty=value or PROP((property
> value)) and just specify a property file that all those system
> properties would be specified in.
>
> Thanks!
>
> david
>
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/java400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/java400-l.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com