Trying to get jar to run as web start/jnlp

I wanted to use web start with my Java game as it gave me access to full screen mode. The downsides are that the user now has to approve the program (as full screen and getting high scores from web both require permissions) whereas before they could just play the game as an applet. The other (rather major) downside is I can’t get it to work outside of my own dev machine (an XP SP3).

Can anyone suggest where I might have gone wrong?

http://www.checkmypages.com/swarm

Many thanks

Mike

Hi

At least one of your JARs is not signed. Don’t forget this rule: all JARs directly mentioned inside a single JNLP file must be signed with the same signature. Your application requires permissions but it gives you the possibility to use much more features, I don’t see that as a downside. You will perhaps buy a “verified” certificate and the warning will look less scary, don’t worry. Thanks for using Java Web Start, it is better than a single fat JAR that might be opened by … WinRAR >:(

JWS doesn’t suffer from the same problem? JNLP files occasionally open with a text or xml editor.

As far as I know, it is occasionally opened by a web browser (MSIE?) as an XML file if Java is not installed under Windows. There are more people using WinRAR than any XML editor and I only had this problem when Java was not installed, Bluefish tried to open JNLP files by default. I assume maybe some people reproduce the same problem under Windows but not with a simple text editor; if you were right, it would be extremely problematic.

It’s actually only one jar. I signed it on my dev PC and then transferred it to the server along with the jnlp file. I’ll be the first to admit I’m feeling around in the dark here. I thought web start and jnlp were almost the same thing but obviously not - I’ll google to find out more. Is it better to use JWS rather than JNLP then?

The downside is that people might get put off running the program if they’re told it requires special permission to run. I think nothing of running any applet but I’m wary of running applications. Why it needs any permissions at all to just run in full screen mode and to access a web page (in the same directory) is beyond me (and perhaps this thread).

I believe a verified cert costs a few hundred $ which, for a free app, doesn’t make sense.

[quote=""]
I seem to get different behaviour depending on which PC I open the page on - my dev PC just goes quiet after loading the Java, my wife’s PC just displays the XML on screen, none actually play the game which is a bit frustrating.

EDIT: actually when I run on my PC now it downloads the app, starts of Java, asks if it’s OK to run and then says it’s unable to run the application :
Name : Retro arcade game …
Publisher : Mike Robinson
From file :// ???

JWS is a technology. JNLP is the XML protocol it uses. So JNLP IS JWS.

Now I opened your JNLP file in a text editor and this is what I saw:


codebase="file:///C:/Java/AlienSwarm/">

Uhhhhhh so how is that gonna be found on my computer? ;D
You’re supposed to put the link to the website the JAR is on, which in this case is http://www.checkmypages.com/swarm/

The following two conditions have to be true:

  • CodeBase + JarName = link to JAR.
  • CodeBase + JNLP file name = link to the JNLP file.

Also, you need ‘href=’ right below the ‘codebase entry’

When I made these changes, the game ran fine :slight_smile:

That explains it. Can I just compile and sign on the server then and it will all start to work? I use the following command to sign:

jarsigner -keystore yourKeystore test.jar YourName

(Well spotted by the way)

Mike

As long as the ‘keystore’ is on the server, then yes.

  • I altered the jnlp file which pointed at the local file - I just removed the codebase entry which I believe should make it use the current directory. Same issue.
  • I transferred 2 files from my dev machine - one concerning a keystore and one my “company” name. Same issue.
  • I tried recompiling the jar and resigning it - it said key will expire in 6 months. Same issue.
  • I tried to create a new cert in my name but it said “the Key pair not generated, alias already exists”.

Any other things I should try?

It worked ;D as well as the problems you pointed out, it turned out that recompiling wasn’t so good on the server as I didn’t yet have all the new images there (I was relying on them being in the jar). If anyone feels brave could they try it on their machine. I’d like to know whether it runs (obviously) and if it allows you to enter high scores.

and thanks for your help guys.

Mike

Sorry, I get this:

[quote]net.sourceforge.jnlp.LaunchException: Fatal: Launch Error: Could not launch JNLP file.
at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:600)
at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:889)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:594)
… 1 more
Caused by: java.lang.IllegalArgumentException: Invalid display mode
at sun.awt.X11GraphicsDevice.setDisplayMode(X11GraphicsDevice.java:414)
at AlienSwarm.main(AlienSwarm.java:834)
… 6 more
Caused by:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:594)
at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:889)
Caused by: java.lang.IllegalArgumentException: Invalid display mode
at sun.awt.X11GraphicsDevice.setDisplayMode(X11GraphicsDevice.java:414)
at AlienSwarm.main(AlienSwarm.java:834)
… 6 more
[/quote]
Please don’t create display modes, pick one instance from those already available:
http://docs.oracle.com/javase/6/docs/api/java/awt/GraphicsDevice.html#getDisplayModes()

Anyway, I remind you that AWT full screen mode does not work as expected under GNU Linux with KDE 4, the task bar is drawn above the window :frowning: If you want to work around this bug, you have to use the native windowing system of JOGL (NEWT) or LWJGL.

Thanks for the heads up. I’d (wrongly) assumed that all monitors supported a low refresh 640x480. I’ve corrected this now. I don’t currently have a Unix box to test on but apparently my Rasberry Pi is now on order so this may change.

Does it work now?
Does JWS/JNLP cache the program for a faster start?
Is there a splash screen?
Does the high score thing actually save your score?

Mike

Everything works fine now. It’s not in full screen mode but I don’t mind.

This game installed nicely using JamVM + OpenJDK 7 + icedtea-web on my Raspberry Pi including adding a launcher icon on the Rasperry Pi x11 desktop.
http://www.raspberrypi.org/phpBB3/viewtopic.php?p=178262#p178262

The game did only open an undecorated window, i worked around it by manually hiding the LXDE launchbar and setting the background to a nice black color to get a nice “fullscreen” arcade experience on an old tube.

Most time in the game is spent in the Java2D software rendered draw routines, do consider switching to something hardware accelerated like JogAmp JOGL GL2ES2 profile that work on both desktop and mobile devices by using a common subset of OpenGL ES 2 and OpenGL 2 calls.