Remko
Remko

Reputation: 7340

Change deployment.properties file programmatically

Is there a way to change options in the deployment.properties (the one in the user's appdata folder) programmatically (without directly writing to the file)?

Eg for system options I could use:

System.setProperty("My Property", "My Value");

EDIT: based on @eis answer, the following code (as an example) works:

import com.sun.deploy.config.Config;

public class Main {
    public static void main(String[] args) {
        Config.setMixcodeValue(Config.MIXCODE_ENABLE);
        Config.store();
    }
}

Upvotes: 2

Views: 1023

Answers (1)

eis
eis

Reputation: 53553

Those options are meant to be changed from java control panel.

If it is locked, a user cannot change it:

Any system deployment property, say SomeKey=SomeValue, may be locked by including another key, SomeKey.locked. The key SomeKey.locked may or may not be set to a value; in either case, SomeKey=SomeValue will be locked so that the user cannot change it. If a system deployment property is not locked, then a user will be allowed to change it.

If it isn't, a user can change it through the control panel.

Now, as for programmatic access, in sun implementation classes there is a Config class that provides access to at least some of those properties, such as setCacheDirectory(). For those exposed, that change mechanism probably works.

As for others: based on that class mentioned above, deployment.properties are saved internally as system properties, so I don't see a reason why System.setProperty() wouldn't change those, too. However changing a property like that might or might not have any effect.

Upvotes: 3

Related Questions