通过 JNLP 的 Java Applet:System.Properties 未被“设置" [英] Java Applet via JNLP: System.Properties not being "set"

查看:20
本文介绍了通过 JNLP 的 Java Applet:System.Properties 未被“设置"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经好几年没有在 Java 工作了(这是我的借口).

It is years since I have worked in Java (that's my excuse).

我正在尝试将 Java Swing UI 作为 Applet 启动(之前通过 Web Start 完成).

I am trying to launch a Java Swing UI as an Applet (previously done via Web Start).

我已经修改了 jnlp 文件以反映我知道对小程序来说是必要的更改(例如,使用 applet-desc 而不是 application-desc).

I have modified the jnlp file to reflect the changes that I know are necessary for an applet (e.g. using applet-desc instead of application-desc).

在 jnlp 文件的 <resources> 标签内,我们设置系统属性如下:

Inside the <resources> tag in the jnlp file we set system properties like this:

<property name="java.security.auth.login.config" value="$$context/app/auth.conf"/>

在主类的 init 方法中,我们尝试读取这些系统属性中的一些,并且始终获得null"作为值.

In the init method of the main class we try to read some of these system properties and always get "null" as the value.

  1. 有没有人知道为什么系统属性不粘连"?

  1. Does anyone have any ideas why the system properties aren't "sticking"?

可能相关的奇怪之处:我已将 Java 设置为在运行时打开控制台.当我用这个小程序加载页面时,控制台窗口打开了两次,两个窗口都显示了加载 jnlp 的详细信息,但只有一个窗口继续加载完整的应用程序.

Possibly related strangeness: I have Java set to open the console when something runs. When I load the page with this applet, the console windows opens TWICE, both windows showing the details of loading the jnlp, but only one window continues with the full app load.

更新:

这里是 jnlp 文件:

Here is the jnlp file:

 <?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" >
  <information>
    <title>app</title>
    <offline-allowed/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <resources>
      <j2se version="1.6+" java-vm-args="-Xms128m -Xmx1024m -Xss1m"/>
      <property name="java.naming.factory.initial" value="org.jboss.naming.HttpNamingContextFactory"/>
      <property name="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
      <property name="java.naming.provider.url" value="$$context/invoker/JNDIFactory"/>
      <property name="java.security.policy" value="$$context/app/server.policy"/>
      <property name="java.security.auth.login.config" value="$$context/app/auth.conf"/>
      <property name="login.context" value="client-login"/>
      <property name="jndi.port" value="1099"/>
      <property name="service.impl" value="Remote"/>
      <property name="polling" value="true"/>
      <jar href="cglib-2.1.3.jar"/>
      <jar href="com.jdas.apps.binmgmt.gui.jar" main="true"/>
      <jar href="commons-beanutils.jar"/>
      <jar href="commons-collections-2.1.1.jar"/>
      <jar href="commons-javaflow.jar"/>
      <jar href="commons-lang.jar"/>
      <jar href="commons-logging.jar"/>
      <jar href="ecs-1.4.1.jar"/>
      <jar href="hibernate3.jar"/>
      <jar href="itext-1.01.jar"/>
      <jar href="jade-5.2.3_AGRIS_PATCH.jar"/>
      <jar href="jbossall-client.jar"/>
      <jar href="jboss-j2ee.jar"/>
      <jar href="jcalendar-1.1.4-agris.jar"/>
      <jar href="jhall-3.1.3.jar"/>
      <jar href="looks-all-1.1.jar"/>
      <jar href="odmg-3.0.jar"/>
      <jar href="pvjdbc2.jar"/>
      <jar href="swing-layout-1.0.jar"/>
      <extension name="additional" href="unsigned.jnlp"/>
  </resources>
  <applet-desc main-class="com.jdas.apps.binmgmt.gui.main.BinManagementApp" name="binMgmt" width="1024" height="768" >

  </applet-desc>
</jnlp>

推荐答案

您需要对 JNLP 文件进行签名才能设置系统属性(除了那些具有特殊 豁免).看看您要设置的一些属性!

You will need to sign the JNLP file in order to set system properties (other than those properties that have special exemption). Look at some of those properties you are trying to set!

要签署 JNLP 文件,请在签署 jar 之前在 JNLP-INF/APPLICATION.JNLP 中放置一个字节对字节的副本(最好坚持使用 US-ASCII(!)).

To sign a JNLP file, put a byte-for-byte copy (best to stick to US-ASCII(!)) in JNLP-INF/APPLICATION.JNLP before signing the jar.

这篇关于通过 JNLP 的 Java Applet:System.Properties 未被“设置"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆