More specifically, when I run my java program from the command line before I jar it, I do something like this:
java -cp a.jar;b.jar;c.jar;. -Djavax.net.ssl.trustStore=jssecacerts Main
I can put the jar’s into the Manifest file like so:
Class-Path: a.jar b.jar c.jar
And then create the jar file like this:
jar -cmf MANIFEST Main.jar Main.class
So that when I run it, I can just write:
java -jar Main.jar -Djavax.net.ssl.trustStore=jssecacerts
However, I’d like to simplify my command line even further and specify the -D variable inside the manifest if possible. Based on this reference:
http://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html
It doesn’t seem obvious how to do it, so I’m wondering if there’s any way to do it.
You can’t do it by setting anything in the manifest, however this provides some interesting alternatives that you might consider.
In general, you could put a properties file in your Jar file and access it via the classpath (
Class.getResourceAsStream()) so that will have close to the same effect and you won’t have to change your code when you need to reset properties.