Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Creating a cross-platform launcher  (Read 8537 times)
0 Members and 1 Guest are viewing this topic.
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Posted 2012-08-12 02:32:05 »

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?

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-08-12 03:04:35 »

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). Smiley

Offline ReBirth
« Reply #2 - Posted 2012-08-12 03:28:50 »

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! Grin

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #3 - Posted 2012-08-12 06:25:56 »

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).



Thanks for the direction ra4king.  Grin

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-08-12 07:57:33 »

I'm impressed! Good job and good luck Smiley

Offline gouessej
« Reply #5 - Posted 2012-08-12 09:13:26 »

Hi

Jar should be enough right? you just dont need to put everything into jar.
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.

Offline jmart

Junior Member


Medals: 1



« Reply #6 - Posted 2012-08-12 23:50:55 »

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
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #7 - Posted 2012-08-13 03:09:40 »

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! :-)

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.

Offline jmart

Junior Member


Medals: 1



« Reply #8 - Posted 2012-08-13 03:17:32 »

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! :-)

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.

Offline Z-Man
« Reply #9 - Posted 2012-08-13 06:25:55 »

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.

...snip...
  • Embed a twitter feed
...snip...
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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #10 - Posted 2012-08-13 06:28:44 »

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.



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

Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #11 - Posted 2012-08-13 06:31:10 »

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.

Offline Z-Man
« Reply #12 - Posted 2012-08-13 06:43:49 »

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.

...snip...

Any Swing guru's know how to squelch the white border?
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.

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.
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.
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #13 - Posted 2012-08-13 07:04:00 »


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.


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

Offline Phased
« Reply #14 - Posted 2012-08-13 07:05:58 »

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.
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #15 - Posted 2012-08-13 07:26:27 »

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

Offline Phased
« Reply #16 - Posted 2012-08-13 07:30:47 »

thanks suds Cheesy

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

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #17 - Posted 2012-08-13 08:22:42 »

thanks suds Cheesy

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!~

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #18 - Posted 2012-08-13 22:12:57 »

That code is looking really good so far! Good job Smiley

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.

Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #19 - Posted 2012-08-14 01:08:01 »

That code is looking really good so far! Good job Smiley

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. :-)

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:

1  
2  
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:

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

Output (for me):
1  
user.home: C:\Users\Scott


If there are no real caveats, I'm thinking of using this as my universal game-data directory:
1  
System.getProperty("user.home") + /.dtp/gamename 

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #20 - Posted 2012-08-14 02:06:05 »

This is good enough:
1  
2  
3  
4  
5  
6  
7  
8  
String saveFolder;

if(os.startsWith("Win")) {
    saveFolder = System.getProperty("user.home") + "/Application Data/" + gameName + "/";
}
else if(os.startsWith("linux") || os.startsWith("mac") || os.startsWith("darwin")) {
    saveFolder = System.getProperty("user.home") + "/." + gameName + "/";
}


EDIT: Apparently "Application Data" also works on Vista and 7 for backwards compatibility purposes.

Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #21 - Posted 2012-08-14 02:31:13 »

This is good enough:

..snip..

EDIT: Apparently "Application Data" also works on Vista and 7 for backwards compatibility purposes.

Thanks again Ra4king. Everything I've been reading has been saying that you require administrator rights to write to appdata on windows. I haven't experienced this issue myself because I have UAC disabled completely. But if 90% of people playing my game will be children without admin rights on their parents' PC; and as a result they cant play the game; then I want to avoid appdata at all costs.

The idea that admin rights are required only came from a couple of stackexchange answers. So I'm not sure about the authenticity of the claim. ;-)

At this point I think I'll roll with the appdata directories like in your code anyway; if its good enough for Ra4king and Minecraft, then its good enough for me. :-)

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #22 - Posted 2012-08-14 02:31:37 »

user.home on Linux returns "/home/<username>/". On Linux, all folders that start with '.' are automatically hidden. On Windows they are not, and this leads to cluttering of the home directory. It is best to put it in Application Data because then it's in its proper place in Windows and out of sight.

EDIT: In no way does AppData need administrative privileges. I have UAC enabled and new File(System.getProperty("user.home") + "/Application Data/My Test Folder/").mkdir() successfully creates the folder: "C:\Users\<username>\AppData\Roaming\My Test Folder\"

EDIT: UAC in Windows 7 is actually quite good now. It only prompts me for system-wide changes, like installations. It's now a good second line of defense against viruses, with your AV being the first. I recommend you turn it on Wink

Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #23 - Posted 2012-08-14 02:42:33 »

user.home on Linux returns "/home/<username/". On Linux, all folders that start with '.' are automatically hidden. On Windows they are not, and this leads to cluttering of the home directory. It is best to put it in Application Data because then it's in its proper place in Windows and out of sight.

EDIT: In no way does AppData need administrative privileges. I have UAC enabled and new File(System.getProperty("user.home") + "/Application Data/My Test Folder/").mkdir() successfully creates the folder: "C:\Users\<username>\AppData\Roaming\My Test Folder\"

EDIT: UAC in Windows 7 is actually quite good now. It only prompts me for system-wide changes, like installations. It's now a good second line of defense against viruses, with your AV being the first. I recommend you turn it on Wink

Awesome. That's really good to hear. That should be all the information I need to make this launcher work now. :-) Thanks for everything today and yesterday Ra4king.

Offline Z-Man
« Reply #24 - Posted 2012-08-14 08:44:27 »

This is good enough:
1  
2  
3  
4  
5  
6  
7  
8  
String saveFolder;

if(os.startsWith("Win")) {
    saveFolder = System.getProperty("user.home") + "/Application Data/" + gameName + "/";
}
else if(os.startsWith("linux") || os.startsWith("mac") || os.startsWith("darwin")) {
    saveFolder = System.getProperty("user.home") + "/." + gameName + "/";
}


EDIT: Apparently "Application Data" also works on Vista and 7 for backwards compatibility purposes.

I don't know about XP but on Windows 7 this works great:
1  
2  
3  
if(os.startsWith("Win")) {
    saveFolder = System.getenv("AppData") + "\" gameName + "\";
}
Offline ReBirth
« Reply #25 - Posted 2012-08-14 14:23:32 »

I wonder if we can use other engine like webkit to load html in java.

Offline Danny02
« Reply #26 - Posted 2012-08-14 14:35:54 »

I know that similar ideas come up very often around here Smiley, but what about uploading that launcher right now to github and creat some nice launcher together. A game launcher with update functionality is something which is useful for everybody.
With git everybody can branch and merge stuff together as he likes, so we would end up with perhaps some a bit different launchers, but I think this would be quite great for everybody.

I would also invest some hours into this.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #27 - Posted 2012-08-14 15:17:41 »

I wonder if we can use other engine like webkit to load html in java.

JavaFX has a webkit component.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #28 - Posted 2012-08-14 21:28:30 »

I don't know about XP but on Windows 7 this works great:
1  
2  
3  
if(os.startsWith("Win")) {
    saveFolder = System.getenv("AppData") + "\" gameName + "\";
}

Oh wow I didn't know there was a 'getenv' method. That's basically doing %APPDATA% which resolves to the correct location for XP, Vista and 7.

Offline gouessej
« Reply #29 - Posted 2012-08-14 21:33:32 »

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.


Rather use IzPack in this case.

This is good enough:
1  
2  
3  
4  
5  
6  
7  
8  
String saveFolder;

if(os.startsWith("Win")) {
    saveFolder = System.getProperty("user.home") + "/Application Data/" + gameName + "/";
}
else if(os.startsWith("linux") || os.startsWith("mac") || os.startsWith("darwin")) {
    saveFolder = System.getProperty("user.home") + "/." + gameName + "/";
}


EDIT: Apparently "Application Data" also works on Vista and 7 for backwards compatibility purposes.
I do something more complicated to create desktop shortcuts in my own source code.

I know that similar ideas come up very often around here Smiley, but what about uploading that launcher right now to github and creat some nice launcher together. A game launcher with update functionality is something which is useful for everybody.
With git everybody can branch and merge stuff together as he likes, so we would end up with perhaps some a bit different launchers, but I think this would be quite great for everybody.

I would also invest some hours into this.
Java Web Start, IzPack and GetDown are often enough... Anyway, good luck.

Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (19 views)
2014-09-12 09:08:26

Norakomi (54 views)
2014-09-10 13:57:51

TehJavaDev (63 views)
2014-09-10 06:39:09

Tekkerue (31 views)
2014-09-09 02:24:56

mitcheeb (53 views)
2014-09-08 06:06:29

BurntPizza (37 views)
2014-09-07 01:13:42

Longarmx (23 views)
2014-09-07 01:12:14

Longarmx (27 views)
2014-09-07 01:11:22

Longarmx (26 views)
2014-09-07 01:10:19

mitcheeb (34 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!