Search code examples
javapropertiessentryraven

How to set properties attributes in Java programmatically?


I'm looking over sentry for java and it requires a properties file:

.level=WARN
handlers=net.kencochrane.raven.jul.SentryHandler
net.kencochrane.raven.jul.SentryHandler.dsn=https://<key>:<secret>@app.getsentry.com/<project>
net.kencochrane.raven.jul.SentryHandler.tags=tag1:value1,tag2:value2

It loads the file by: java -Djava.util.logging.config.file=/path/to/app.properties MyClass

I want to set the properties in java source; how do I do that?

It looks like I may be able to use the Properties class? Not sure though (Java isn't my primary language).


Solution

  • In Java you can set properties dynamically by using the System class , just doing for example System.setProperty("java.library.path","value_you_want"); you can achieve it.