Search code examples
javajnlpjava-web-start

JNLP: Cannot pass arguments to main


I wrote a program which simply output args[0]. If no args is passed to the main, then it will output "Hello World"

class test {
public test(String str) {
    System.out.println(str);
}
public static void main(String[] args){
    if (args == null || args.length == 0) {
        args = new String[] { "Hello World" };
    }
    new test(args[0]);
}}

In the .jnlp file, the corresponding part is written as:

<application-desc main-class="test"/>
  <argument>TEST1</argument>
</application-desc>

However, after running this jnlp, it outputs "Hello World"

Can anyone please help me figure out what's the reason?


Solution

  • I solved it by deleting the / in <application-desc main-class="test"/>