1

I need to open a Java Swing application at client side on calling a servlet. Few arguments are also required to be received at the main method of that Swing application which gets opened via JNLP at a client browser. In my case the swing app is getting opened but no arguments are be received in anyway.

My JNLP file is not dynamically built. It is a static file. Here it is:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" 
      codebase="http://localhost:8085/TestWebApp" 
      href="ContactEditor.jnlp">

    <information>
        <title>JNLP Example</title>
        <vendor>Catalyst Software</vendor>
        <homepage href="http://localhost:8085/TestWebApp" />
        <description>JNLP Testing</description>
    </information>

    <security>
        <all-permissions/>
    </security>

    <resources>
        <j2se version="1.6+" />
        <jar href="ContactEditor.jar" />
    </resources>

    <application-desc main-class="my.contacteditor.ContactEditorUI">
        <argument>00001</argument>
        <argument>Harish Prasad</argument>
        <argument>220153429088</argument>
    </application-desc>    

    <security>
        <all-permissions/>
    </security>

</jnlp>

Please suggest how to pass arguments dynamically from the servlet to the swing application.

My questions are:

  1. What code do I have to write at my Swing program?
  2. What do I have to mention in the JNLP file?
  3. How should I pass the values from the servlet?
domids
  • 515
  • 5
  • 21
  • 2
    Be sure to check the JNLP using JaNeLA, available at my [share drive](https://drive.google.com/drive/#folders/0B5B9wDXIGw9lUnJaUjA2cmlVRE0). Note that JNLP above has two `` elements.. – Andrew Thompson Sep 19 '16 at 23:24

1 Answers1

2
  1. The JNLP File Syntax specifies that "Each argument contains (in order) an additional argument to be passed to main."

    public static void main(String[] args) { 
        for (String value : args) {
            …
        }
    }
    
  2. Your <argument>syntax appears correct, as specified here; the <security> element appears twice, as noted here; verify the syntax as noted here by @AndrewThompson.

  3. You'll need to construct the JNLP file dynamically, as discussed here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    *"syntax appears correct"* The `` element appears twice. – Andrew Thompson Sep 19 '16 at 23:27
  • @AndrewThompson: Thank you for critical review; I was too focused on the `` syntax. Thanks also for linking to `JaNeLA`. Is there a canonical Q&A that cites it? I'd be happy to edit broken links if you see fit. – trashgod Sep 20 '16 at 01:10
  • *"Is there a canonical Q&A that cites it?"* Most of my canonical Q&As have been (heavily upvoted but) closed. Afraid that one would attract accusations of 'spam'. :( – Andrew Thompson Sep 20 '16 at 02:22
  • @AndrewThompson: [Hypnotoad](http://futurama.wikia.com/wiki/Hypnotoad) suggests, "Some of the tools formerly available at my pscode.org domain can be downloaded from my [Google Share Drive](https://drive.google.com/folderview?id=0B5B9wDXIGw9lUnJaUjA2cmlVRE0)." – trashgod Sep 20 '16 at 06:55