Web Start 无法加载外部驱动程序 [英] Web Start unable to load external driver

查看:28
本文介绍了Web Start 无法加载外部驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个作为 Java 应用程序的项目,它运行良好,直到我将其纳入 Web Start.我的项目依赖外部库来处理串口和USB口.

I have a project as Java application, and it was running fine until I made it into web start. My project relies on external library to deal with serial port and USB port.

运行这个应用程序.在 DOS 命令中:

To run this app. in DOS command:

java -DPropLoc=Drivers.Properties -jar myprog.jar <args>

In Netbeans 6.7.1 JRE 1.6u21, When select WebStart as Project Configuration, I can run the the main project but it failed to load the driver.在项目属性中,我将 VM 选项设置为 -DPropLoc="Drivers.Properties,并且驱动程序依赖于该文件.但是,如果我进行调试并逐步进行,它将加载驱动程序并且运行正常.

In Netbeans 6.7.1 JRE 1.6u21, When select WebStart as Project Configuration, I can run the the main project but it failed to load the driver. In the Project Properties, I have the VM Option set to -DPropLoc="Drivers.Properties and the driver relies on this file. But if I do debug and with step by step, it will load the driver and thing run OK.

web start 启动有什么问题?

What is the problem with the web start launch?

这是我加载驱动后得到的错误:

This is the error I got after loading the driver:

Caught java.lang.NullPointerException: name can't be null while loading driver com.sun.comm.Win32Driver
javax.comm.NoSuchPortException at javax.comm.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:105)

由于我不明白为什么它在NB中一步一步调试时加载了驱动程序.但是通过按 F6 运行主项目,它不会加载驱动程序.Debug 和 Run 的环境或 JVM 有什么区别.

Since I don't understand why it loaded the driver when debugging in NB step by step. But by running the main project by pressing F6, it won't load the driver. What is the difference of environment or JVM between Debug and Run.

下面是launch.jnlp文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/bit9prog/dev/NetBeansProjects/MyProg/dist/"  href="launch.jnlp" spec="1.0+">
<information>
    <title>MyProg</title>
    <vendor></vendor>
    <homepage href=""/>
    <description>MyProg</description>
    <description kind="short">MyProg</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+"/>
<property name="PropLoc" value="Drivers.Properties"/> 
<jar eager="true" href="MyProg.jar" main="true"/>
<jar href="lib/comm.jar"/>
<jar href="lib/config.jar"/>
<jar href="lib/jakarta-regexp-1.4.jar"/>
<jar href="lib/log4j-1.2.14.jar"/>
<jar href="lib/swing-layout-1.0.jar"/>
<jar href="lib/trove.jar"/>
<jar href="lib/XmlUtil.jar"/>
</resources>
<application-desc main-class="MyProg">
<argument>r</argument>
<argument>.</argument>
</application-desc>
</jnlp>

推荐答案

这是一个安全问题.因为您的驱动程序正在执行本机访问,所以必须对其进行签名,如果驱动程序已经签名,则将其添加到 jnlp 文件的方式略有不同.

This is a security issue. Because your driver is doing native access it has to be signed, and if the driver is already signed then the way that you add it to your jnlp file is slightly different.

例如使用您的证书签名的内部库,则条目如下所示

For example with an internal library that is signed using your certificate then the entry look as follows

        <jar href="myLibrary.jar"/>

但是对于由其他人签名的资源,您的条目看起来像这样

However for a resource that is signed by somebody else your entry looks like so

<extension href="Driver.jnlp" name="Driver" version=""/>

它需要自己的JNLP文件

And it needs its own JNLP file

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+"
codebase="{yourcodebase}" href="Driver.jnlp">
    <information>
        <title>Driver</title>
        <vendor>Driver Corporation</vendor>
    </information>
    <resources>
        <jar href="lib/TheExternalDriver.jar"/>
    </resources>
    <security>
        <all-permissions/>
    </security>
    <component-desc/>
</jnlp>

这篇关于Web Start 无法加载外部驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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