How to set preferIPv4Stack property for JNLP app?

拥有回忆 提交于 2019-12-10 11:23:46

问题


I need to set java.net.preferIPv4Stack=true to an app started via JNLP (javaws and applet)

Tried those, without luck...

<j2se ...java-vm-args="-Djava.net.preferIPv4Stack=true" />
<property name="java.net.preferIPv4Stack" value="true"/>
System.setProperty("java.net.preferIPv4Stack", "true");

The only way i could make it work was seeting when launching javaws from local filesystem:

javaws -J-Djava.net.preferIPv4Stack=true myapp.jnlp

What is not possible on a applet or URL.

How should i set this property?


回答1:


With the Java 7 Update 6 (b17) the list of secure properties has been updated. See Bug Report 716069 for further Details.

You can include this setting by specifying the following line within the resource tag:

<property name="java.net.preferIPv4Stack" value="true"/>




回答2:


The only properties that you can set in the JNLP are those considered secure which do not include java.net.preferIPv4Stack.

The alternative options you have are (not tested):

  • pass the parameter directly to javaws like you did: javaws -J-Djava.net.preferIPv4Stack=true myapp.jnlp
  • Java Control Panel > Java > View > Runtime Parameters, but that is a global setting for all webstart applications and applets using the version of the JRE for which you changed the setting
  • use an environment variable: JAVAWS_VM_ARGS = -Djava.net.preferIPv4Stack=true
  • flag the setting as secure by adding a line to the deployment.properties file, located in the Deployment Home(*) : deployment.javaws.secure.properties=java.net.preferIPv4Stack - note: not sure if this is available Java > 1.5.

The first 3 options are detailed in this document.

(*) Deployment Home:
Windows XP: %HOME%\Application Data\Sun\Java\Deployment
Windows 7/Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment
Linux/Solaris: %HOME%/.java/deployment




回答3:


Also, for future readers - environment variable for applets:

_JPI_VM_OPTIONS

e.g.

_JPI_VM_OPTIONS=-Djava.net.preferIPv4Stack=true



来源:https://stackoverflow.com/questions/9809919/how-to-set-preferipv4stack-property-for-jnlp-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!