0

I have a jar file with two main classes. Depending on what I need I can run one or the other. To have this application run via webstart I created two JNLP files, each of them referencing one of the two main classes.

It is mindboggling to see that only one of the main classes is started from both files! What I know is the class that gets fired up is also the one listed as main-class in the jar's manifest. I tried to read the webstart specs, the webstart documentation but cannot find anything related to the manifest here. When I tried to look at the source code (shipped with the Oracle JDK) I did not see much related to the webstart launcher at all.

So how exactly does webstart find its main class?

Queeg
  • 7,748
  • 1
  • 16
  • 42

2 Answers2

1

In the JNLP file, you have a resource section where you put your jar.

One of you jar should be main=true. In this jar you define the main-class in the MANIFEST.MF like a standalone jar file.

Cyrille Pontvieux
  • 2,356
  • 1
  • 21
  • 29
  • The main jar is declared main=true. But it contains two main classes. The way you state it seems that it is well-knows the manifest is evaluated. That implies that the main-class attribute is not looked at. – Queeg Nov 17 '14 at 16:20
  • Could you not have used a single main class and provide command line arguments or system properties to decide which path to take? It's been a while since I have done web start but I think you can set system properties in the JNLP file. – markbernard Nov 17 '14 at 16:55
  • You can set system properties and other parameters. Just wanted to make sure I really understand this webstart behaviour before going for workarounds. – Queeg Nov 18 '14 at 08:14
  • In the meantime I tried having a single main class that takes a command line parameter to run the desired application. Again I got a surprise that despite the two JNLP files now point to the same main class and it is this main class that gets launched in both cases, both calls show the same parameters being passed - this is where my files definitely vary. I do not understand why one JNLP file should know the content of the other, unless there is some codebase or caching issue. And again I do not find any reference in documentation or source. – Queeg Nov 24 '14 at 15:19
0

To give additional information, here are snippets from my JNLP files:

<resources>
    <jar href="FarmGenerator.jar" main="true"/>
    ...
</resources>
<application-desc main-class="com.amadeus.wh.farmgenerator.MainFrame">
</application-desc>

This is a snippet of the second JNLP:

<resources>
    <jar href="FarmGenerator.jar" main="true"/>
    ...
</resources>
<application-desc main-class="com.amadeus.wh.CompliancyChecker.MainFrame">
</application-desc>

This is the manifest file snippet:

Main-Class: com.amadeus.wh.farmgenerator.MainFrame

From both JNLP files only the farmgenerator.MainFrame is launched. As if the manifest overrides the application-desc element.

Queeg
  • 7,748
  • 1
  • 16
  • 42