LWJGL Packing-up and Shipping-out

OK, after my little OpenAL break-through I had today, I’m totally sold on using LWJGL for my game development. Heck, I may even try OpenGL one of these days; but for now, OpenAL and Java2D will have to do until I get smarter. :-/

Anyway, I’ve about got a working rough-draft of my very first game completed (SO exciting)! But now that I’m using LWJGL, I have some complicated issues/questions.

  1. How do I pack it all up into a jar that someone can just download, double-click, and launch? Do I HAVE to use jnlp (I can’t stand the whole security certificate thing for applications)?

  2. Is there a way to pack up LWJGL with my game so that it’s still cross-platform compatible? (Do I have to include all versions of lwjgl in the jar or something?)

  3. Is there a way to pack up the LWJGL .DLLs and .SOs along with the application so that the end-user doesn’t have to worry about installing them seperately?

I’m very concerned with keeping it simple for the end-user, as well as cross-platform compatibility (particularly windows and linux, although Mac would be nice once the lwjgl is finished for it).

Any help would be appreciated.

A webstartable version is only needed if you want to launch over the internet.
If not, it gets rather easy depending on how you do it :slight_smile:
a) jar your files, include the prejared lwjgl, include dlls/so/jnilib, add launcher script for each platform
b) jar classes, add a jar manifest (no expert here) - people should them be able to execute it by double clicking the jar, or typing java -jar <myapp.jar>

I would probably go for a
layout:

start.bat
start.sh
start.(mac launch type thingy)

\libs
lwjgl*.jar
myapp.jar
lwjgl.dll
lwjglaudio.dll

and so forth…

For a Windows distributable I would go with the following setup:

  1. For users that don’t know anything about Java and don’t want to install a JRE, bundle a stripped down version of the JRE with the game (optional libraries can be removed from the JRE package, to reduce its size). This adds about 15MB to the download size.

  2. For users with an existing JRE installation, offer a smaller download package, with no JRE bundled.

Use Bootstrap (http://www.g0dmode.com/javastuff/bootstrap-1.0.zip) or similar utility to smooth out the starting of the application/game. This adds a nice polishing touch to your product, compared to ugly batch scripts (with no icons, etc…).

Package the whole thing with a nice installer, like NSIS2 for Windows (http://nsis.sourceforge.net/).

Cheers

/me awaits 3*blah to come and bash nnevatie with a big webstart

[quote]/me awaits 3*blah to come and bash nnevatie with a big webstart
[/quote]
/me joins Middy and waits for the great bashing to start - while preparing his arguments of why Webstart is not good for Everything™

Matzon,

How would you call the startup script from within the jar? And how do you tell your application which lwjgl set (dll or so) to use?

Do you have to extract the appropriate lwjgl somewhere first?

Sorry, I’m a complete newbie on this - I’ve been focused so much on just making a game, that I failed to think about packing it all up in the end (packing was easy until I started using LWJGL actually).

If you are creating a distribution, then on your installation you can check for the property “os.name” to find out what is installed.

You also have the option of using IzPack(http://www.izforge.com/izpack/) to create your distribution. It is a full featured installer written in Java. This way everything is in one package.

[quote]A webstartable version is only needed if you want to launch over the internet.
[/quote]
Why not just use Java 5 and use the install-from-CD-webstart? Ease-of-install of webstart, coupled with CD distribution

[quote]I’m totally sold on using LWJGL for my game development.
[/quote]
Java? yep. LWJGL? yep. So now we just need to sell you on webstart too…

Learn JNLP. Make JNLP your friend. Achieve nirvana. Then get pissed off when you discover that one teensy little thing you want/need to do just doesn’t work because of some incomprehensibly obvious oversight or bug in Sun’s design/implementation.

No, seriously: webstart is worth learning, once, because in most situations its as close to perfect as you’re going to get. It only takes minutes to get the hang of it and from then on you can make your own educated decisions.

For your situation, it’s easy:

  • you have your game code in JARs (as many as you like)
  • you put a line in webstart for each platform (linux, windows, etc) that tells it to use the official LWJGL webstart, and don’t even have to worry about how it’s all packaged up!

Oh, sorry - is there no official LWJGL JNLP extesnion? ::). Well, in that case you need to make a JAR for each platform, with different names ;), and put a line in the JNLP for each platform, telling webstart which JAR has that platforms specific stuff.

Could it BE any easier?

[quote]How would you call the startup script from within the jar?
[/quote]
I wouldn’t. I would let the bat fil (or shellscript) call the the java runtime, specifying commandline parameters.

Ok, thank you guys for all the help. I think I will dive into jnlp, but for the meantime, I’ve got it all in a zip file, running with a .bat (on Windows) and .sh (on Linux).

I’m having one big issue however: On linux, it won’t even launch. I keep bombing out with a SIGSEGV Hotspot VM error as soon as I try to start it. Anyone else see this before? I didn’t have this issue until I started using LWJGL for the audio.

Oh, and for the JNLP stuff, is there a way to have it NOT check for a security certificate when launched locally? And will it work with LWJGL if the user is offline?

is there a way to have it NOT check for a security certificate
when launched locally?

Not really, but you can use a selfcert.

And will it work with LWJGL if the user is offline?

If offline mode is allowed, yes. However, using offline allowed during beta/test phase isn’t recommended, because you would need to start the app twice (in a row) in order to get it updating.

[quote]Ok, thank you guys for all the help. I think I will dive into jnlp, but for the meantime, I’ve got it all in a zip file, running with a .bat (on Windows) and .sh (on Linux).
[/quote]
A quick warning: like many linux users (I have no idea what percentage, but when I mention it I get a lot of “me too” comments), I will deliberately not run a .sh file (…for a java app).

The landscape is changing now that people have to accept Sun’s JVM’s crappy initialization requires a runtime JVM parameter (e.g. -Djava.library.path=.), but at least 3 in every 5 java games I’ve ever tried to run with a sh file had broken shell scripts, and often did stupid things like trying to mess with my classpath settings - insult to injury! No. Refuse.

Shrug. Maybe people don’t mind any more. Maybe authros are much better at shell scripts now. But personally if it’s not webstart I simply can’t be bothered (not evangelism, just laziness) to run it any more.

OK, please tell me there’s a simpler way to sign jars now. Please, please, please?

Ok, I’m impressed with the JNLP stuff. I just got the thing working on Windows and Linux without any hassles… EXCEPT for asking for that security certificate authorization. That could kill someone trying to release a pro app. How much does a “trusted” certificate cost these days? And how long does it last?

Still too expensive for hobby use at least, we are talking 100eds of $ a year.

You can get one for free from Thawte, it’s not as good as a certificate you pay for, but it’s free :slight_smile:

The certificate will be shown as being distributed by Thawte Freemail Member and if you live in the USA it seems like you can get your own name shown by joining the Thawte Web of Trust.

Here’s a good howto

http://www.dallaway.com/acad/webstart/

scroll down to the Certificates section.

One more oddity that I’ve noticed with the JNLP stuff - my game doesn’t perform as well as it does running straight from Eclipse. ???

Any ideas? I don’t have any solid benchmarks or anything, but I’ve noticed that when I run it under eclipse, it’s smooth, and there’s no clipping of my sprites as they redraw. However, after packing it into a JNLP, I noticed skipped frames and clipping. Is there something I’m missing in my JNLP file?

<?xml version="1.0" encoding="utf-8"?>



BallBounce 0.6 alpha
TommyTwisters.com

Catch the red balls!
Catch the Balls




























Ok, Murphy’s Law is at it again… as soon as I post my problem, a solution pops into my head. :-[

I was using a timer that was “limiting” my frame per second to 60. For some reason, it was obvious when run via jnlp, but not eclipse (perhaps Eclipse gives applications a higher thread priority when run?). I simply took out the hold, and use nothing but a thread.yield at the end of my animation loop. I’m using Java2D with createbufferstrategy, and I have to wonder if it’s handling all of the frame synchronization and stuff for me automatically (I seem to remember reading something about that somewhere).

I figure, since everything in my game is based on elapsed time with the nanotimer, that should be fine (so long as Java2D really is handling it all automatically).

MURPHY STRIKES AGAIN!!!

Now I have a different problem. I can launch my game with absolutely no problems via eclipse, or the command line java.exe. However, if I launch from a JNLP I’m all of a sudden getting “Unable to Launch” “Width (0) and height (0) cannot be <= 0”. I was cleaning up code, but I kept testing it and running it successfully from command line. Ugh. Anyone know what could be causing this?

It’s always hardest to have the rug pulled out from under your feet when you’re right at the top of the stairs. :’(

ok elias444, and others…

what was your jarring process? I cant get my game to find any of the lwjgl stuff when running from a jar. I though I had it working, but when I move the jars to a fresh directory…no go.