Create a .java.policy file in your home directory. You can also grant a finer granularity of permissions on specific properties (for example, mytool.demoMode
), rather than all properties.
grant { permission java.util.PropertyPermission "mytool.*", "read"; };
Add code in your tool to access the property:
String serviceType = "Wbem"; try { String serviceTypeProp = System.getProperty("mytool.serviceType"); if (serviceTypeProp != null) serviceType = serviceTypeProp; } catch (Exception ex) { } if (serviceType == "Wbem") // do something for Wbem else if (serviceType == "Demo") // do something for Demo ...
Start SMC, and specify property on command line:
/usr/sadm/bin/smc -J-Dmytool.serviceType=Demo