通过JNLP文件将参数传递给java web start应用程序

时间:2017-07-26 14:31:27

标签: java arguments java-web-start jnlp

我是Java编程的初学者,我正在尝试制作Java Web Start应用程序。我需要通过JNLP将一些args传递给应用程序。当我在Web应用程序中对值进行硬编码时,没有args的JNLP工作正常,并启动应用程序。此外,当从带有参数的cmd启动应用程序时,它正在工作。所以我认为问题出在JNLP文件中。当我尝试使用包含参数的JNLP启动应用程序时,启动失败并显示错误:

java.lang.ArrayIndexOutOfBoundsException: 0

JNLP文件如下:

   <application-desc main-class="SpeedScanLaunch" >
       <argument>http://localhost/TestApp/Dam/</argument >
       <argument>x</argument >
       <argument>50004</argument >
   </application-desc >

和Java类看起来像:

import java.io.*;
import javax.swing.JOptionPane;

public class SpeedScanLaunch    
{
    public static void main(String args[])throws IOException
{   String p = args[0];
    String t = "/type:" + args[1];
    String id = "/id:" + args[2];
    JOptionPane.showMessageDialog(null, p);
    JOptionPane.showMessageDialog(null, t);
    JOptionPane.showMessageDialog(null, id);
...

有谁知道JNLP的问题是什么? 另外,screnn freom JaNeLa: Screenshot from janela

来自JaNeLa的文字报道:

JaNeLA Report - version 11.05.17


Report for file:/E:/eclipse_workspace/TestProjekt/bin/SpeedScanLaunch1.jnlp

Content type application/xml does not equal expected type of application/x-java-jnlp-file
cvc-complex-type.2.4.d: Invalid content was found starting with element 'security'. No child element is expected at this point.
cvc-complex-type.2.4.d: Invalid content was found starting with element 'security'. No child element is expected at this point.
XML encoding not known, but declared as utf-8
Codebase '.' is a malformed URL!  Defaulting to file:/E:/eclipse_workspace/TestProjekt/bin/SpeedScanLaunch1.jnlp
Codebase + href 'file:/E:/eclipse_workspace/TestProjekt/bin/SpeedScanLaunch.jnlp' is not equal to actual location of 'file:/E:/eclipse_workspace/TestProjekt/bin/SpeedScanLaunch1.jnlp'.
Optimize this application for off-line use by adding the <offline-allowed /> flag.
Codebase '.' is a malformed URL!  Defaulting to file:/E:/eclipse_workspace/TestProjekt/bin/SpeedScanLaunch1.jnlp
Codebase '.' is a malformed URL!  Defaulting to file:/E:/eclipse_workspace/TestProjekt/bin/SpeedScanLaunch1.jnlp
Codebase '.' is a malformed URL!  Defaulting to file:/E:/eclipse_workspace/TestProjekt/bin/SpeedScanLaunch1.jnlp
Downloads can be optimized by specifying a resource size for 'SpeedScanLaunch.jar'.
The resource download at SpeedScanLaunch.jar can be optimized by removing the (default) value of download='eager'.
The resource download at SpeedScanLaunch.jar can be optimized by removing the (default) value of main='false'.
It might be possible to optimize the start-up of the app. by  specifying download='lazy' for the SpeedScanLaunch.jar resource.
Lazy downloads might not work as expected for SpeedScanLaunch.jar unless the download 'part' is specified. 

0 个答案:

没有答案