Search code examples
javajava-web-start

Java Webstart - Putting server IP in jnlp file


Is there a way to use a variable in a java webstart JNLP file so that the application that is sent to a client will have the server IP address?

My application needs to open a socket back to the server to fetch non-jar configuration files (which I am currently able to do via a hardcoded server address). I'm trying to see if there is a way to get the IP dynamically. Thanks for any help!


Solution

  • Since there are few people willing to answer webstart questions, you can create variables via the JNLP file that are accessible from the resulting Java application:

    Put these inside the resources tags in the JNLP file:

    <property name="jnlp.serverip" value="192.168.0.50"/>
    <property name="jnlp.serverport" value="8080"/>
    

    Note they MUST each start with "jnlp.". They can be accessed within the webstart app via

    System.getProperty("jnlp.serverip");