Let's talk distribution!

Since the jerk I bought my DSi off on Ebay decided to not mail it, I’ll talk to you guys until it lands. :slight_smile:

We’ve probably all seen comments about what types of java distributions are broken, and I’m sure many has thought “Then what do I do?”
I want to ask that question, now. I fear that much of these comments contains outdated information, so let’s try to assemble the options we have, as of this post.

To my knowledge, there are problems with applets tearing on Macs, and being unsafe. Also, JNLP simply not launching in some instances.
So far, I’ve just packaged it all manually inside a zip. This is a pain to do manually, and updating an application becomes hell.

Is there an easy way to put all resources, libraries and binaries into a single jar that will launch?
Also, is there a way to set up our IDE’s to do this, upon distribution?

Lastly, I’d like to know more about our options for distributing just the updater, that will launch the application as well - like Minecraft does it.
I understand you could do it yourself, but being indies I understand we would like to avoid spending more time on distribution than on the actual game development.

If you’ve distributed a game ever, please share your experiences. This is from IDE, to consumer. We’d like to minimize the steps.

Let the discussion begin. :slight_smile:

Applets - shit.
JNLP - shit.

Distribute proper installers/packages for whatever platform(s) you are targeting. On Windows that’s a .exe or .msi installer; on MacOS a zipped .app or a .dmg; and on Linux, .debs, .tar.gz and maybe .rpms. If you were properly nifty you’d install an autoupdater and get it to autoupdate on first run and thereafter. That’s something we’re going to look into.

Cas :slight_smile:

I have a commercial application, where I simply made an installer that contained an .exe that kicked off (the embedded) JVM with certain hardcoded arguments. It also contained a tiny jar, which was only able to download 1 file, and had some addional logic.

The actual application was not in the installer.

That tiny app was able to download a hardcoded URL, containing plain text like:


lib/my-data.jar
lib/some-stuff.jar
lib/other-tools.jar
res/splash.jpg

the app would then iterate over these URLs, using the If-Modified-Since header, and overwriting any files that were updated on the server. Then it would kick off the main application. That’s it. It’s easy to ‘deploy’ a new version of your app (just FTP some files).

The user still thinks it’s a proper installer (compress the installer with LZMA, once!), and the auto-update typically takes only a few seconds on a reasonably fast connection. Otherwise, render a fancy progressbar. You could say that the ‘tiny app’ is a JNLP client, but it’s much simpler, and well, works.

I haven’t had a single complaint and many happy customers.

[quote]To my knowledge, there are problems with applets tearing on Macs
[/quote]
My 10.6.6 iMac can’t even play Left 4k Dead without an incredible amount of lag.

And occasionally I run into problems where an applet isn’t destroyed properly and begins slowing my computer down to a crawl (even if I’ve quit Chrome).

Haven’t really found problems with JNLP, except that it performs significantly slower than a downloaded JAR.

Riven’s technique is spot on and you might be interested to know about Getdown which is an open sourced library that does more or less what he’s done. LWJGL also has some code (in the LWJGL applet stuff) that does similar.

Cas :slight_smile:

Further advice: do not rely on URLConnection. It will fail, every once in a while. I don’t know why, I just know it does from years of experience.

With your own HTTP/1.0 client in under an hour and you’ll have a robust downloader.

I was unaware! Thank you for sharing.

What is the benefit from having an executable? I suspect it could just as well be written in Java?
Also, how does one embed a JVM?

Making an executable gives the application a native feel. Plus the additional bonus of a file icon :wink:

Embedding a JVM is as simple as including the JRE folder that came with your install.

The best way to make executables for all platforms is to use Launch4J.

I’ve never heard of URLConnection just randomly failing. What was an issue (fixed by 1.5) was that if you had even slightly flakey DNS, negative results were cached too aggressively. That would affect everything doing hostname lookups, not just URLConnection. URLConnection is broken in other ways though, like setReadTimeout() not working once you’ve started to receive data. Rolling your own HTTP client is lunacy – use Apache HTTPComponents instead. I fetch many thousands of URLs a day with it, many of them from sites that are not the most cooperative in the world.

Thanks r4aking, thats getting bookmarked

I found that using Ant is a must, if you want to use any tools.
However, it seems there are millions of sh*t tutorials out there, and it’s impossible to find anything objective.
I have tried for several hours now, to find a solution to this.

What do I have to do, to compile my sources in Eclipse - however, and this is where half the internet fails apparently, I want to reference libraries
that I don’t have the source of, Such as Slick-Utils.
It’s been absolutely unheard of, during my google searches.

I also want to put the natives into a folder somewhere, where it can be used, and seen, and not cause a brazillian errors.

If anyone could post an ant script that works with Eclipse, and builds a LWJGL/Slick app, that would be great.

Sorry for unnecessary rage. Nothing is going as it should today.

TIL, Ant causes more frustration than this. http://www.youtube.com/watch?v=ww_PjqYQi5E

Actually, the majority of java libraries these days are built with Maven. I hardly ever touch ant.

http://lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Maven

The sample pom on that page includes slick too.

Not sure If I understand your problems, but I do my whole application bundling with Ant.
Just specify a classpath built of required libraries:

...

Use it for compiling:

And copy the libraries in your zip-bundle or whatever with appropriate Ant tasks.

Maven indeed. Ant also works, but since Eclipse is in play, m2eclipse is a really great plugin to integrate Maven support into Eclipse. I’m not sure, but I think you need the Eclipse for JEE developers distribution to be able to use it though.

The real powerhouse is a combination of Maven and ANT though. There are some things that Maven just cannot do (without developing another plugin) and you need the flexibility of ANT. As an example, I needed a way to generate a properties file per project with the maven pom version in it for displaying purposes in a webapp - so it was easy to see what versions of components were installed and if they were snapshot or release versions. A simple combination of Maven invoking ANT’s ‘echo’ task in the pre-package phase already did the trick.

You sure about that??? The website seems to say you can only make Windows executables, though you can build them cross platform.

On the installer and update front, I’m a great fan of the NetBeans runtime container, which is fairly lightweight, provides cross-platform installers, and has a great module system which would allow you to easily push updates. You can also ship with an embedded JVM.

Another installer I’ve been investigating recently for a different purpose is IzPack. It’s cross-platform, and written in Java, though with native wrappers. Not sure you can embed a JVM yet - seems to be an outstanding issue.

izPack seems really cool, but the downside is that it generates an installer that requires a Java runtime to execute; exactly the one thing you’d like the user not to be bothered with.

I see all the different packaging tools and they are all about 50% of what I’d really want to have. I think it is not as difficult as having to generate launchers or wrappers at all. I think for a decent solution that covers most if not all needs, you’d need:

  • a tool that can package up an application with a minimized bundled runtime of your choice
  • configurable launcher applications (windows/linux/mac, compiled for 32 bits and 64 bits), for which the packaging tool can bundle one that matches the bundled runtime

The first requirement shouldn’t be too difficult to create, although it should be flexible enough that it can understand “JVM configurations” like Java 6, Java 7, Java 8 - to be able to deal with Oracle changing the layout. If you could for example setup some kind of index file for each runtime then new runtimes can be supported without having to create a new version of the packaging tool.

The second requirement will probably require some teamwork to create matching launchers with identical behavior for the different platforms, but it is a far easier way of doing it than generating executables on the fly. Probably create the Windows version, offer the source code and then someone with knowledge of another operating system environment could port it. Anything that needs to be project specific, stick it in a configuration file that the launcher application can read and then use to for example fork the JVM process. The packaging tool can wrap that all up so the user doesn’t have to be bothered with it. But the configuration file still leaves open flexibility to change properties after installation, such as heap space settings.

Like this, the “hard work” is left up to us in stead of the end user. What we’d need to do is:

  • generate downloadable packages for each viable environment that you want to support
  • create a download page which will automatically choose the proper download package based on the HTTP headers sent by the browser (if possible)

The user basically only has to download, install and then run without having to think much about it. Like any other application. It seems like I covered everything. That is unlikely however, so what did I miss? Yeah a version 2.0 feature: the launcher applications can check for updates the Minecraft launcher way :slight_smile:

[quote]It’s possible to wrap applications on Windows, Linux, Mac OS X and Solaris!
[/quote]
;D

-snip-

Somehow I managed to double post.

;D
[/quote]
Yes, I read that, and also this -

[quote]The wrapped program works on all Windows platforms (98/Me/NT/2K/XP/Vista), Launch4j works on NT/2K/XP/Vista, Linux, Mac OS X (build on 10.4) and Sparc Solaris 8-10.
[/quote]
which as I said suggests that you can build on any platform, but the executable only works on Windows.

@gimbal - IzPack looks great, and allows you to create platform-specific executables, but does have that issue with needing a JVM installed. Hopefully there’ll fix that one day! The NetBeans installer infrastructure does support most of what you want. Bundling the JVM can be a bit awkward to set up though - http://wiki.netbeans.org/NBIBundledJVM

I’ve used URLConnection to fetch tens of thousands of files from the web. About 1.0% of them failed. Then I wrote my own less-than-100-lines HTTP/1.0 implementation, and 0.0% failed. That’s all I needed to know. To be fair, my latest tests were in december 2010, but that’s not anywhere near ‘the 1.5 era’.

LWJGL ditched URLConnection due to similar issues and bugged caching.