Load getdown application with JNLP

400 views
Skip to first unread message

Anthony Bargnesi

unread,
Jan 7, 2014, 9:04:21 AM1/7/14
to ooo-...@googlegroups.com
Hello,

I am starting to use getdown in order to ship the save JRE to all clients, but I would like to avoid platform installers.

Is there a way to call the GetdownApp from JNLP without a getdown.txt file?  I have tried the following JNLP descriptor:

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

    <information>
        <title>My App</title>
        <vendor>Company, Inc.</vendor>
        <offline-allowed/>
    </information>

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

    <update check="timeout" policy="prompt-update"/>

    <resources>
        <property name="jnlp.appbase_domain" value="http://localhost/" />
        <property name="jnlp.appdir" value="." />
        <property name="jnlp.appid" value="My App" />
        <j2se version="1.5+"/>
        <jar href="getdown-latest.jar" main="true"/>
    </resources>

    <application-desc main-class="com.threerings.getdown.launcher.GetdownApp"/>
</jnlp>

This failed to bring up the getdown UI and no JNLP error occurred.

Thanks!

Tony Bargnesi

Michael Bayne

unread,
Jan 7, 2014, 2:01:23 PM1/7/14
to ooo-...@googlegroups.com
On Tue, Jan 7, 2014 at 6:04 AM, Anthony Bargnesi <abar...@gmail.com> wrote:
Is there a way to call the GetdownApp from JNLP without a getdown.txt file?

That's some wishful thinking!

It's not possible to use Getdown without a getdown.txt file. You can try using Getdown in applet mode if you want to avoid per-platform installers, but applets are increasingly disabled in modern web browsers.

It looks like there's a way to use JNLP to run an applet, so you might try doing that.


Anthony Bargnesi

unread,
Jan 9, 2014, 5:44:09 AM1/9/14
to ooo-...@googlegroups.com
Michael,

Thanks for the reply.  I find the need for a getdown.txt too constraining if all getdown needs is the appbase.  Though I might be missing something there.

I was able to get this working by adding a main class to getdown that writes the getdown.txt (to some target application directory) with just the appbase.  Then it calls GetdownApp.main.

package com.threerings.getdown.launcher;
...
public class Bootstrap {

    static final File HOME = new File(getProperty("user.home"), "application");

    public static void main(String[] args) {
        if (args.length != 1) {
            throw new RuntimeException("usage: Bootstrap [appbase]");
        }

        // write out getdown.txt with appbase
        HOME.mkdir();
        writeGetdownTxt(HOME, args[0]); // appbase
        // call Getdown using "user.dir" as appdir
        GetdownApp.main(new String[] {HOME.getAbsolutePath()});
    }

    /**
     * Write out a getdown.txt file with an {@code appbase}.
     *
     * @param appbase String
     */
    public static void writeGetdownTxt(File home, String appbase) {
        File f = new File(home, "getdown.txt");
        BufferedWriter w = null;
        try {
            w = new BufferedWriter(new FileWriter(f));
            w.write(format("appbase = %s", appbase));
        } catch (IOException e) {
            throw new RuntimeException("Cannot write getdown.txt.", e);
        } finally {
            if (w != null) {
                try {
                    w.close();
                } catch (IOException e) {
                    throw new RuntimeException("Error closing writer.");
                }
            }
        }
    }
}

My jnlp file would be application specific, but just provide the getdown jar file with the appbase.  The jnlp codebase and getdown appbase are the same for simpler deployments, but they don't need to be.


<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+"
      codebase="http://host/"
      href="run.jnlp">

    <information>
        <title>App</title>
        ...

    </information>

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

    <update check="timeout" policy="prompt-update"/>

    <resources>
        <j2se version="1.5+"/>
        <jar href="getdown-latest.jar" main="true" />
    </resources>

    <application-desc main-class="com.threerings.getdown.launcher.Bootstrap">
        <argument>http://host/</argument>
    </application-desc>
</jnlp>

Great project btw.  I had to ship a specific JVM for a Groovy application and it worked beautifully.

Thanks,
Tony

Anthony Bargnesi

unread,
Feb 8, 2014, 10:05:14 PM2/8/14
to ooo-...@googlegroups.com
The main class Bootstrap is committed to my fork (https://github.com/abargnesi/getdown).  Dropping it here for reference to the original problem.

-tony

Michael Bayne

unread,
Feb 11, 2014, 1:09:28 PM2/11/14
to ooo-...@googlegroups.com
On Thu, Jan 9, 2014 at 2:44 AM, Anthony Bargnesi <abar...@gmail.com> wrote:
> Thanks for the reply. I find the need for a getdown.txt too constraining if
> all getdown needs is the appbase. Though I might be missing something
> there.

I agree that it would be nice to be able to bootstrap things with a
system property. The idea of launching Getdown via JNLP is kind of
comical, but also not totally crazy since the JRE goes to all the
trouble to wire up Java Web Start, so it's nice to leverage that
vector into running signed code, even if one doesn't use JNLP for the
application updating and whatnot.

Anyhow, I'll put in support for passing appbase via a system property
which Getdown can fall back to if it doesn't find a getdown.txt file.

-- m...@samskivert.com
Reply all
Reply to author
Forward
0 new messages