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

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

问题描述

我有一个项目作为Java应用程序,并且在进入Web启动之前一直运行良好.我的项目依靠外部库来处理串行端口和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>

在NetBeans 6.7.1 JRE 1.6u21,当选择在webstart为项目配置,我可以运行的主要项目,但它没有加载驱动程序. 在项目属性中,将VM Option设置为-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.

网络启动启动有什么问题?

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键运行主项目,不会加载驱动程序.调试和运行之间的环境或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天全站免登陆