简体   繁体   中英

How to modify Java Control Panel selections (corresponding to deployment.properties file) from windows command prompt?

How to modify Java Control Panel selections (corresponding to deployment.properties file) from windows command prompt? Specifically, I am looking for command(s) which can effect change in "Action for local applets" selection, in "Custom Security Level Settings" window (click the "Settings..." button next to "Custom" setting for the "Security Level" slider in the Security tab in Java Control Panel) , from "Prompt user" to "Run without prompt" . This setting's default value changed with update 11 of Java 7 and it interferes with operation of an automated-test program, which I am fixing now, by having a Security Warning dialog window pop-up when IE starts java.exe, unless this Java Control Panel setting is adjusted a priori. This test program launches IE to run a local Java applet, which is written using AWT, and which doesn't access any websites.

Note, this problem has been discussed recently -- see https://service.parachat.com/knowledgebase/273/I-see-a-Do-you-want-to-run-this-application-security-warning.html

For my task, modifying this Java Control Panel setting manually is the least desirable way to solve the problem because the program, which I am fixing, is a part of an automated test suite, which is deployed on many machines, and requiring manual intervention makes the deployment process error-prone. I need these commands to run from a windows command prompt batch file.

I found that these security level selections are recorded in Java deployment.properties file and in 2 Windows registry under keys with names ending in "Software\\JavaSoft\\DeploymentProperties". deployment.properties file is discussed comprehensively in Oracle Java SE Documentation "Deployment Configuration File and Properties" but nothing obvious is mentioned about "Action for local applets" , maybe because this property is a recent addition (?) When I adjust Java Security Level and "Action for local applets" in the Java Control Panel, I see the changes reflected in the deployment.properties file as well as in the DeploymentProperties registry keys.

So I can do the following:

  1. adjust the deployment.properties file via script (saving the original)
  2. start Java Control Panel via script -- I observed that this copies the updates from the deployment.properties file to the registry keys DeploymentProperties
  3. terminate the javaw process which runs the Java Control Panel

    • then run the program which uses my local Java applet within IE
    • then revert the deployment.properties file to the original, start Java Control Panel via script, and terminate the javaw process which runs the Java Control Panel.

I also tried it vice versa -- update the registry key -- but the file does not change and Java Control Panel reverts the registry keys' value set back to agree with the unmodified deployment.properties file! So updating the registry keys is a wrong way to do it.

Is there a better way to do this? My 3-step solution above (to modify the properties) is a kluge for what it is meant to accomplish. Is there a Java command-line utility which can modify a given deployment property? Is there a way to pass these deployment properties to JVM via applet tag's attributes, to be effective only within the given Java applet?

I used Windows XP (both 32-bit and 64-bit) and Windows 7 (64-bit) and Internet Explorer 7, 8 and 9. It would be good to have a (simple) solution which works on Windows XP, Windows Vista, Windows 7 and Windows 8.

Just make your own deployment.properties file and put it in the *{User Application Data Folder}\\LocalLow\\Sun\\Java\\Deployment* location. Or edit the existing file. Need internet browser restart.

As described in http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/properties.html

Set it on installation as per article below:

http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/client-security.html

On installation, the WEB_JAVA_SECURITY_LEVEL argument has the following effect:

WEB_JAVA_SECURITY_LEVEL=VH sets the security level to very high
WEB_JAVA_SECURITY_LEVEL=H sets the security level to high
WEB_JAVA_SECURITY_LEVEL=M sets the security level to medium
WEB_JAVA_SECURITY_LEVEL=L sets the security level to low

After installation of the JRE, verify the security level settings in the Java Control Panel.

I've done my testing with java 7u25

When you place deployment.properties here c:\\windows\\sun\\java\\deployment\\deployment.properties

The next time javaw is run or the control panel is opened (also runs javaw), the new settings take effect.

You should in theory be able to drop a new deployment.properties file using your script, immediately run your app. Close the app. Then copy the original deployment.properties file back to restore security settings.

I'd also like to mention that you can get rid of the "Do you want to run this application" box by changing the location it stores the trusted certificates store to a shared location. The putting a trusted.certs file in there that was generated by manually approving a certificate on any other computer. Note that the extra slashes are necessary as the colon is a reserved character and the backslash is the escape character.

#moves the user trusted certificates store to a shared location so we can pre-approve controls
deployment.user.security.trusted.certs=C\:\\Program Files\\Java\\jre7\\security\\trusted.certs

Just search for "Configure Java", which will open the "Java Control Panel". The file it's in your JRE folder.

OR, you could go to the "Control Panel" and click in the "Java" icon.

In there just reduce or increase the security level as you wish.

I hope I have helped.

Have a nice day. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM