Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 26, 2013 2:40 am

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Webstart question
PostPosted: Wed Jun 25, 2008 4:47 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
Can someone take a quick look and help me fix this webstart. The thing will load and crash:

Code:
<?xml version="1.0" encoding="utf-8"?>
<jnlp
  spec="1.0+"
  codebase="http://localhost/games"
  href="asteroidz.jnlp">
  <information>
    <title>Asteroidz</title>
    <vendor>Alex Schearer</vendor>
    <description>The classic asteroids.</description>
    <description kind="short">The classic asteroids.</description>
  </information>
  <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+" max-heap-size="128m" />
   <jar href="asteroidz.jar" /> 
   <jar href="lib/phys2d.jar" />
    <extension href="http://slick.cokeandcode.com/demos/slick.jnlp" />
  </resources> 
  <application-desc main-class="asteroidz.Asteroidz" />
</jnlp>


The exception is:
Code:
org.newdawn.slick.SlickException: Game.render() failure - check the game code.
   at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:551)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:351)
   at asteroidz.Asteroidz.main(Asteroidz.java:23)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at com.sun.javaws.Launcher.executeApplication(Launcher.java:1178)
   at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1125)
   at com.sun.javaws.Launcher.continueLaunch(Launcher.java:968)
   at com.sun.javaws.Launcher.handleApplicationDesc(Launcher.java:522)
   at com.sun.javaws.Launcher.handleLaunchFile(Launcher.java:218)
   at com.sun.javaws.Launcher.run(Launcher.java:165)
   at java.lang.Thread.run(Thread.java:613)


Thanks so much, sorry for yet another webstart problem, but I can't seem to figure it out.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 5:31 pm 
Offline
Regular
User avatar

Joined: Sun Feb 24, 2008 6:31 pm
Posts: 163
Location: UK
Silly question, but I take it this works when run locally as looks more like a problem in the code rather than a config error.

MikeD

_________________
Work In Progress:
Atic Atac Remake
MegaBlast (First Slick Game I started)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 5:43 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
Yea, it runs when I start it from Eclipse. I don't suppose the error could be related to lwjgl and native libraries? For instance, perhaps I need to add something for macs (which I am running) and other platforms?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 6:14 pm 
Offline
Regular
User avatar

Joined: Sun Feb 24, 2008 6:31 pm
Posts: 163
Location: UK
I too develop on a Mac. I've posted a copy of the JNLP I use for one of my projects.

Code:
<?xml version="1.0" encoding="utf-8"?>
<jnlp
  spec="1.0+"
  codebase="http://www.jbloomfield.net/michaeldaley/webstart/aa"
  href="aticatac.jnlp">
  <information>
    <title>Atic Atac</title>
    <vendor>Mike Daley</vendor>
    <homepage href="http://www.jbloomfield.net/michaeldaley"/>
    <description>Atic Atac</description>
    <description kind="short">Atic Atac</description>
    <icon href="icon.gif"/>
  </information>
  <security>
     <all-permissions/>
  </security>
  <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+" max-heap-size="128m"/>
    <jar href="aticatac.jar"/> 
    <extension href="http://slick.cokeandcode.com/demos/slick.jnlp"/>
  </resources> 
  <application-desc main-class="com.daleyuk.games.atic_atac.Atic_Atac"/>
</jnlp>


There are some handy ant build scripts which come with Slick under the Scripts folder in the slick distribution. I use those to build the project, assemble the jar and produce the webstart jnlp and then update to the net. Its worth checking them out as once its working it speeds up this stuff in future.

MikeD

_________________
Work In Progress:
Atic Atac Remake
MegaBlast (First Slick Game I started)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 6:19 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
Thanks so much, hopefully between these two things I can get this ready. I am totally new to Slick and didn't know about those ant scripts, thanks for the tip!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 6:25 pm 
Offline
Regular
User avatar

Joined: Sun Feb 24, 2008 6:31 pm
Posts: 163
Location: UK
No problem. I also posted some more info on your bouncing text question here http://slick.javaunlimited.net/viewtopic.php?t=1110

Have fun

MikeD

_________________
Work In Progress:
Atic Atac Remake
MegaBlast (First Slick Game I started)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 6:35 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
Alright, I've inched a little further and have a new question. Right now I am getting the following error:

Unsigned application requesting unrestricted access to system
Unsigned resource: http://localhost/games/lib/natives-mac.jar

However, I have tried to sign my jar (following the instructions here: http://www.cokeandcode.com/webstarthowto). As far as I can tell my jar should be signed, so what gives?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 6:38 pm 
Offline
Regular
User avatar

Joined: Sun Feb 24, 2008 6:31 pm
Posts: 163
Location: UK
I had something similar before and had to add the security section to the jnlp.

Code:
  <security>
     <all-permissions/>
  </security>


That sorted it for me.

MikeD

_________________
Work In Progress:
Atic Atac Remake
MegaBlast (First Slick Game I started)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 6:41 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
I have that as well, here's my updated jnlp

Code:
<?xml version="1.0" encoding="utf-8"?>
<jnlp
  spec="1.0+"
  codebase="http://localhost/games"
  href="asteroidz.jnlp">
  <information>
    <title>Asteroidz</title>
    <vendor>Alex Schearer</vendor>
    <description>The classic asteroids.</description>
    <description kind="short">The classic asteroids.</description>
  </information>
  <security>
   <all-permissions/>
  </security>
  <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+" max-heap-size="128m" />
   <jar href="asteroidz.jar" /> 
   <jar href="lib/phys2d.jar" />
    <extension href="http://slick.cokeandcode.com/demos/slick.jnlp" />
  </resources> 
    <resources os="Mac">
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+" max-heap-size="128m"/>
    <nativelib href="lib/natives-mac.jar"/> 
  </resources> 
  <application-desc main-class="asteroidz.Asteroidz" />
</jnlp>


I imagine my jar isn't signed -- I mean that's what the error is saying, but I'm not sure why.

*update*

When I sign the jar I get a warning that it will expire in 6 months, could this have an impact on things?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 6:53 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
I just fixed the problem. In case future developers run into the same thing it was due to the fact that the native jar wasn't signed (and also some other ones). So I just signed all of the jars I was including.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 7:06 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
At this point I'm running into a problem loading the resources. How should I specify resources such that they can be loaded from the jar? Right now I have simple relative paths, e.g.

res/laser.wav

This leads to an error:
Code:
org.newdawn.slick.SlickException: Failed to load sound: res/laser.wav
   at org.newdawn.slick.Sound.<init>(Sound.java:70)
   at asteroidz.Ship.<init>(Ship.java:26)
   at asteroidz.Level.initShip(Level.java:132)
   at asteroidz.Level.init(Level.java:109)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:155)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:337)
   at asteroidz.Asteroidz.main(Asteroidz.java:23)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at com.sun.javaws.Launcher.executeApplication(Launcher.java:1178)
   at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1125)
   at com.sun.javaws.Launcher.continueLaunch(Launcher.java:968)
   at com.sun.javaws.Launcher.handleApplicationDesc(Launcher.java:522)
   at com.sun.javaws.Launcher.handleLaunchFile(Launcher.java:218)
   at com.sun.javaws.Launcher.run(Launcher.java:165)
   at java.lang.Thread.run(Thread.java:613)



Sorry, I'm totally new to this jar business, too.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 7:25 pm 
Offline
Regular
User avatar

Joined: Sun Feb 24, 2008 6:31 pm
Posts: 163
Location: UK
I just add my res folder to the jar file, or, jar up your res folder and add that to the main jar file. Also make sure you have not got a / in front of the folder reference e.g. it should be res/laser.wav and not /res/laser.wav.

MikeD

_________________
Work In Progress:
Atic Atac Remake
MegaBlast (First Slick Game I started)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 8:10 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
miked, can you do me a favor and show me the command you'd execute if you had one package and one resource folder to jar?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 8:29 pm 
Offline
Regular
User avatar

Joined: Sun Feb 24, 2008 6:31 pm
Posts: 163
Location: UK
Code:
jar uf yourjar.jar res/**

_________________
Work In Progress:
Atic Atac Remake
MegaBlast (First Slick Game I started)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 25, 2008 8:35 pm 
Offline
Oldbie

Joined: Tue Jun 17, 2008 5:11 pm
Posts: 336
Thanks, I actually just figured it out (finally). Long story short I was referencing resources as follows:

Code:
Music m = new Music("res/song.wav");


That doesn't work in the jar. First I needed to add the res directory to my classpath then I needed to switch to:
Code:
Music m = new Music(getClass().getResource("res/song.wav")


Hope that helps someone down the road.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group