Creating a cross-platform launcher

I’ve been using LWJGL for a couple of years now. I’m fairly comfortable with it. I’ve gotten to the deployment stage with one of my projects. So far I’ve experimented with packaging it as a zip file and letting people extract it and run the executable jar manually, that’s a bit messy. I used JarSplice to create a single cross platform executable jar, that was less messy; but cramming 100mb of game files into a single jar and having people re-download the whole thing every time there’s an update is not appealing to me.

I’m looking for suggestions on how to get started with creating a Minecraft style launcher application. I want to:

  • Embed a twitter feed
  • Check for newer versions and update changed files
  • Use the “home” directory of the user, %appdata% on windows, the actual home directory on Linux variants
  • Provide some click-able links in a sidebar

I’m confident that I can learn how to provide all of the features described on my own; but I don’t know where to start. Should I be using C++, Java, C#, Mono or something else? How do I create a cross platform native application? I’m a game developer; I don’t know the first thing about regular applications. What is my best option to create something like this?

What other options that promote user convenience are there?

Minecraft’s launcher uses Swing, which has some useful components for embedding links, images, etc… (like JEditorPane)

As for an updater, I suggest either Java Web Start or GetDown (preferable). :slight_smile:

Jar should be enough right? you just dont need to put everything into jar.

ra4king, show us your previous post describing this fat jar please! ;D

Hey hey thats awesome! Spent this morning learning the ins and outs of swing. Rigged this functional prototype up. Loads a html page from an external server and the launch button actually launches the game (and closes the launcher).

https://dl.dropbox.com/u/18809996/launcher.png

Thanks for the direction ra4king. ;D

I’m impressed! Good job and good luck :slight_smile:

Hi

I already said that JAR may be opened by the archiver (WinRAR, Arc, …) instead of running the Java application, packaging a Java application as a single JAR is a bad idea.

There are already some quite good installers like Java Web Start, IzPack and GetDown. I don’t see the interest of creating another one. Anyway, good luck.

Are you coding in Netbeans? The nice people of the JavaFX community have created Native packaging support using Ant commands that work with 3 free installers, one for MAC, Win, and Linux. I currently got it working with the Windows installer Inno Setup 5. It works great and by default it installs in AppData. I imagine you can either get Inno Setup 5 yourself and give it a shot, you write the Inno Setup 5 script and compile. Also I can send you the Inno Setup 5 script that the JavaFX Ant script creates. Also, the Ant script bundles your JRE with your package. It might take a little bit of work to figure it out but the results are great. I get to use which ever JRE I want.

https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx

thanks
jose

Hey, its not so much an installer, as it is a launcher. It will act as an installer, but any time the user wants to run they game, they’ll do it via the launcher. This will feed them any news related to the game, and automatically download any updates to the game before allowing them to launch it directly.

I use IntelliJ IDEA, but I’ll look into that jmart. Thanks! :slight_smile:

gouessej, I agree that packaging the whole game in a jar file is a bad idea. Which is why I’m opting for the launcher in the fist place.

Its not free but its feature rich… Install4J.

http://www.ej-technologies.com/products/install4j/overview.html

I used the evaluation and it is the truth.

You could try Launch4j, it doesn’t make an installer but it does wrap a JAR file in an EXE file.

I believe that Minecraft’s launcher uses HTML The Minecraft homepage his a twitter feed on it which means you could use HTML to display the twitter feed, however I think it uses javascript as well (this might help with that). So they just put everything into an HTML file and have it embedded in the launcher. Of course this isn’t the only way to do it. You could have a separate embedded HTML page for the twitter feed, you could use Twitter’s Search API to search for and list the tweets from a certain twitter account, or (it looks like) you could use the Public streams part of Twitter’s Streaming API to do it as well.

I’m having a bit of an issue with these swing controls. So far all the functionality I want is there, almost effortlessly. But I can’t seem to get rid of this white border. The components in question are a JEditorPane embedded in a JScrollPane, embedded in a JFrame.

https://dl.dropbox.com/u/18809996/launcherborderproblem.png

Any Swing guru’s know how to squelch the white border?

Yeah ZMan, I understand that. They use a tumblr blog with a super minimal theme. I’ve just set up a similar system today. The launcher now pulls a tumblr blog with a custom html-only theme I’ve made. (tumblr throws a random quantserv script in though - weird). At this point I’m looking at writing a program that’ll run locally and pull all the data I want from various sources manually, then write them to a html file.

Try calling setBorder(new EmptyBorder(0,0,0,0)) on your JScrollPane.
EDIT: I think you may have to call setBorder(new EmptyBorder(0,0,0,0)) on the JFrame as well.

I edited my post to expand to other possibilities of getting the info from Twitter. I haven’t tried any myself but it looks like you could hack together something that way.

Bingo! Thanks for the help! Actually had to call it on the JEditorPane. :slight_smile:

Would you mind making just the launcher opensource?

I was wondering how to make the same kind of launcher, I started, just ran into some troubles with the layout.

Phased, the code so far:

http://pastebin.java-gaming.org/a75081a2120

You’re not meant to hardcode positions and stuff, but I want to lock this to a specific size/location. There’s also probably some redundant calls to stuff because I’m learning swing for the first time - so I’m testing different functionality

thanks suds :smiley:

Noticed your Australian too! WIN! we need more game developers here!

Hey, no problems! There are plenty of Aussie devs about, you just need to know where to look. :-p Twitter is a good place to start.

But of course, the more the merrier!~

That code is looking really good so far! Good job :slight_smile:

For updating, it’s not that hard to implement your own updater. Just have it test against a version file on the server for each file, with the launcher downloading the new version of each file. It’s not that hard if you know how to properly use the java.net and java.io packages.

Thanks for the input. :slight_smile:

Thats exactly what I have planned to do. (Spent a few hours in bed last night reading up on exactly those; java.net and java.io packages). The challenges that I’m going to face next though; detecting the OS group, and based on the result I want to put the downloaded files in specific directories. I’m thinking %appdata% works for Minecraft on windows, so it may as well work for me too. I’m thinking along the lines of a .hidden directory in the user’s home folder on linux, and I have no idea how mac’s work - never used one. So I have no idea what directory is appropriate with those.

I’m not sure yet on how to detect the OS, but if I can’t do it in code, then I suppose I’ll just have to have three different launchers. It would be silly to download the windows natives onto a linux box, and vice versa.

EDIT:
So I’ve found System.getProperty(“os.name”); To be used like this:


String os = System.getProperty("os.name").toLowerCase();
return (os.indexOf("win") >= 0);

Will return true if the OS is windows. Cascading if-statements with “win” switched out for “nux”, “nix”, “mac” or “sunos” will detect which of the popular OSes we’re using.

So now I’m back to choosing an appropriate directory for game files for each OS.

EDIT 2:
I’ve been a minecraft player for a couple of years now - its what made me switch from XNA/C# to LWJGL/Java. I don’t know if there is a specific reason of benefit of using appdata or the application support folders. But my research just now suggests that the user.home property is available on all OSes, and doesn’t require administrator rights to write to. Sounds almost ideal, unless there’s a reason not to? Just out of curiosity, can someone on linux and or mac give me the output of:

System.out.println("user.home: " + System.getProperty("user.home"));

Output (for me):

user.home: C:\Users\Scott

If there are no real caveats, I’m thinking of using this as my universal game-data directory:

System.getProperty("user.home") + /.dtp/gamename