Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java Webstart Problem  (Read 3901 times)
0 Members and 1 Guest are viewing this topic.
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Posted 2004-06-01 07:53:51 »

Hello,

I am trying to make a webstart version of my game, but i have a problem. Everything works fine if I startup the game from my local disc, and have my data (models, textures, ..) in a directory; although all this data is also in the jar. When I startup the jar from somewhere else I don't need the data dir. Only when I try to run the webstart application. What am I doind wrong here ?

Here is the webstart code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://users.pandora.be/kozen/demos" href="Sample.jnlp">
<information>
  <title>JOGL Sample</title>
  <vendor>K. Development</vendor>
  <description>JOGL Demo</description>
</information>
<offline-allowed/>
<security>
      <all-permissions/>
</security>
<resources>
  <j2se version="1.4+" />
  <jar href="Sample.jar"/>
  <jar href="Resources/jogl.jar"/>
</resources>
<resources os="Windows">
    <j2se version="1.4+"/>
    <nativelib href="Resources/jogl-natives-win32.jar"/>
  </resources>
  <resources os="Linux" arch="i386">
    <j2se version="1.4+"/>
    <nativelib href="Resources/jogl-natives-linux.jar"/>
  </resources>
  <resources os="OSX">
    <j2se version="1.4+"/>
    <nativelib href="Resources/jogl-natives-macosx.jar"/>
  </resources>
  <resources os="Mac OS X">
    <j2se version="1.4+"/>
    <nativelib href="Resources/jogl-natives-macosx.jar"/>
  </resources>

<application-desc main-class="Sample" />
</jnlp>


Regards,
Kenzo
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #1 - Posted 2004-06-03 00:07:48 »

It's impossible to tell without knowing how you load your data. If you limit yourself to ClassLoader.getResourceAsStream() and similar APIs for fetching your data then things should work fine off the local disk and with Java Web Start. See the source code for the JOGL demos at http://jogl-demos.dev.java.net/ and the JNLP files they use. In particular look at VertexProgRefract and its fetching of its images.
Offline TheBohemian

Junior Member




Java will rule them all!


« Reply #2 - Posted 2004-06-03 11:51:07 »

@Guoshima:
are you aware of the fact that "Resources" has to be a folder on your server?

some exception traces and the like would be really helpful.

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #3 - Posted 2004-06-09 21:01:15 »

Sorry for long dealy, was out away for a few days, but I still have the same problem. To load my files I simply use the following methods:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public static URL getResourceURL(final String filename) throws IOException {
        // Try to load resource from jar
       URL url = ClassLoader.getSystemResource(filename);
        System.out.println("Resource url: "+url);
        // If not found in jar, then load from disk
       if (url == null) {
            return new URL("file", "localhost", filename);
        } else {
            return url;
        }
    }

    public static InputStream getResourceAsStream(final String filename) throws IOException {
        // Try to load resource from jar
       InputStream stream = ClassLoader.getSystemResourceAsStream(filename);
            System.out.println("Resource stream: "+stream);
        // If not found in jar, then load from disk
       if (stream == null) {
            return new FileInputStream(filename);
        } else {
            return stream;
        }
    }


When i try to run a simple sample program from a jar, this gives no errors. He always finds the extra jars for JOGL, ... but he can't seam to read my data, which is also in the jar. I get a null pointer when I try to create the data. This is the error:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
Resource stream: null

java.io.FileNotFoundException: data\glass.png (Het Systeem kan het opgegeven pad niet vinden)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(Unknown Source)
      at java.io.FileInputStream.<init>(Unknown Source)
      at ResourceRetriever.getResourceAsStream(ResourceRetriever.java:30)
      at TextureReader.readImage(TextureReader.java:29)
      at TextureReader.readTexture(TextureReader.java:23)
      at TextureReader.readTexture(TextureReader.java:15)
      at Sample.createTexture(Sample.java:427)
      at Sample.init(Sample.java:511)
      at net.java.games.jogl.impl.GLDrawableHelper.init(GLDrawableHelper.java:68)
      at net.java.games.jogl.GLCanvas$InitAction.run(GLCanvas.java:187)
      at net.java.games.jogl.impl.windows.WindowsGLContext.makeCurrent(WindowsGLContext.java:144)
      at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:110)
      at net.java.games.jogl.impl.GLContext.setRenderingThread(GLContext.java:253)
      at net.java.games.jogl.GLCanvas.setRenderingThread(GLCanvas.java:148)
      at net.java.games.jogl.Animator$1.run(Animator.java:89)
      at java.lang.Thread.run(Unknown Source)


I placed my little demo online at http://users.pandora.be/koze/demos/. If you check the java console, you'll see the error, and you can also check that the data is in the Jar. I also placed my source code inside the jar. Hope someone can find my error, so i can put my game online :)
Offline ribot

Junior Member




Ribot - mobile UI specialist


« Reply #4 - Posted 2004-06-10 01:10:15 »

Error:

The requested URL /koze/demos/ was not found on this server.

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #5 - Posted 2004-06-10 06:51:36 »

sorry typo: http://users.pandora.be/kozen/demos/
Offline ribot

Junior Member




Ribot - mobile UI specialist


« Reply #6 - Posted 2004-06-10 07:20:40 »

Ok, just so you know - I get exactly the same problem here.

System: Win XP (SP2), Java 1.4.2_04

It looks like your developing off the same texureReader and resource file classes as I.  I've got a long list of developmental progressions for my own work today, but hopefully will be able to fit into it all a little JNLP test by the end of the day.

Looking at your JNLP file, I can see nothing that stands out as incorrect, but instead of your format which follows:

1  
2  
3  
4  
5  
6  
<jnlp spec="1.0+" codebase="http://users.pandora.be/kozen/demos" href="Sample.jnlp">
<information>
  <title>JOGL Sample</title>
  <vendor>K. Development</vendor>
  <description>JOGL Demo</description>
</information>


I would use this (not sure if it will have any effect whatsoever):

1  
2  
3  
4  
5  
6  
7  
8  
9  
<jnlp 
  spec="1.0+"
  codebase="http://users.pandora.be/kozen/demos/"
  href="Sample.jnlp">
<information>
  <title>JOGL Sample</title>
  <vendor>K. Development</vendor>
  <description>JOGL Demo</description>
</information>

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #7 - Posted 2004-06-10 08:54:28 »

> java.io.FileNotFoundException: data\glass.png

Don't use backslashes Roll Eyes

弾幕 ☆ @mahonnaiseblog
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #8 - Posted 2004-06-10 13:20:47 »

strange .. but I don't write backslashes in my code. Java makes backslashes out of them. Will try the native getDefaultSeperator or something .. know it excists, just have to find how and where Smiley
Offline kevglass

JGO Kernel


Medals: 120
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #9 - Posted 2004-06-10 13:29:12 »

In fact you don't want to use Files at all in webstart applications. However, your "ResourceRetriever" class would indicate that you're aware of this... but FileInputStream simple won't work to access files from a jar?

Odd...  Huh

Kev

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

JGO Coder


Medals: 1


pixels! :x


« Reply #10 - Posted 2004-06-10 13:37:05 »

>Will try the native getDefaultSeperator or something

Ops... my bad. Nah there is no need to. Just keep the usual slashes and everthing is fine... and a leading slash is also a good idea... eg "/snd/blam.ogg".

弾幕 ☆ @mahonnaiseblog
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #11 - Posted 2004-06-10 13:42:00 »

well .. I tried the native seperator by calling System.getProperties("file.separator"), but then I always get "\". And the jar executable won't work either then.

Changed everything back to normal, and added the filename also in the output, and I get this:

1  
2  
3  
4  
5  
6  
System separator: \
Resource stream: null with filename: data/glass.png
java.io.FileNotFoundException: data\glass.png (Het systeem kan het opgegeven pad niet vinden)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(Unknown Source)      at java.io.FileInputStream.<init>(Unknown Source)
...


so you see that I call py using "data/glass.png", but then he changed it to data\glass.png .. presume this is a windows thing. So I don't know what I am doing wrong here .. !

All these people who made Java Webstart games, how do they do it to load their files .. ? I presume all the data is also in the jar ..
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #12 - Posted 2004-06-10 14:03:24 »

Nah. There is nothing wrong.

It gets converted to the path style of the underlying OS... so it's perfectly normal that you get a '\' there at the end (if you are using windows).

And yes, the images go into the jar file, too. So do you have a sub dir in the jar called "data" with a file called "glass.png" in it?

弾幕 ☆ @mahonnaiseblog
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #13 - Posted 2004-06-10 14:04:25 »

Quote
and a leading slash is also a good idea... eg "/snd/blam.ogg".

I've found that a leading slash will work fine for locally run (ie, from IDE) apps, yet fail when in webstart. Leaving it off works in both.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #14 - Posted 2004-06-10 14:13:48 »

yip .. there is subdir data with glass.png in it. And it works fine when I perform following command: java -jar Sample.jar

perhaps there is something wrong with the Jarsigner or so. How do you need to sign a jar. I simple used the following method: (from http://java.sun.com/developer/technicalArticles/Programming/jnlp/)

Quote

1. First, create the JAR file:
jar cf JNLPTime.jar TheTime.class
2. Second, create a key in the keystore (or use one you already have). You'll be prompted for information like first name and last. You should at least fill in that information.
keytool -genkey -keystore myKeys -alias jdc
3. Third, sign the JAR. Be sure to remember your password from the previous step.
jarsigner -keystore myKeys JNLPTime.jar jdc


is the this correct ?
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #15 - Posted 2004-06-10 14:20:54 »

Quote

I've found that a leading slash will work fine for locally run (ie, from IDE) apps, yet fail when in webstart. Leaving it off works in both.


Mmmh? Huh

http://people.freenet.de/ki_onyx/rmfjuke.jnlp (*) (~96kb)

Leading slashes used there.

(* Sounds like poo without a soundbank [you get one with the sdk but none with the jre])

弾幕 ☆ @mahonnaiseblog
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #16 - Posted 2004-06-10 15:01:53 »

Quote
In fact you don't want to use Files at all in webstart applications. However, your "ResourceRetriever" class would indicate that you're aware of this... but FileInputStream simple won't work to access files from a jar?

Odd...  Huh

Kev


This is what I mentioned a couple of weeks ago in our ResourceLoader class for survivor (thinks: perhaps we should post that code here somewhere? It's quite nice with the override...)

Currently, Sun JVM's have dodgy support for URL's and File's and JAR-URL's and their interaction. One side-effect is that you CANNOT use "file://" URL's in some places in java where you would expect you could. Another is that you don't seem to be able to use "peeking-inside-a-JAR" URL's in places where you might expect to be able to - in particular, you CANNOT use FileInputStream on these things.

...which, IIRC, is all wrong: the JVM has a clever system of "protocols" where you should be able to add a single "protocol" and that makes all URL's everwhere understand that protocol. But all I know is that it hasn't worked properly any of the last 3 or 4 times I've tried it.

So:
- never use FileInputStream in a JAR environment
- never use File in a JAR environment (without FIS, it's largely useless anyway, but IIRC it doesn't understand JAR's either - so you can't make use of the .exists() methods etc, making it ENTIRELY useless)
- never rely upon URL-based methods, because in various situations they just don't work (when logic would suggest they should)
- when using getResourceAsStream, bear in mind that it WILL return you a non-null InputStream when IT CANNOT FIND THE RESOURCE!

...which is why I took Kev's ResourceLoader class and added lots of special-casing code so that it could do what most of the above methods OUGHT to do by default, but don't: you give it the name of a file you want to load and it gets an InputStream either from a JAR or from a File, automatically picking whichever it can find..

malloc will be first against the wall when the revolution comes...
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #17 - Posted 2004-06-10 15:15:36 »

thanx for the help .. and would you mind sharing that loader with us. Might be very very handy for a few of us .. !
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #18 - Posted 2004-06-14 07:51:26 »

well .. I  still haven't fixed my web start problem yet. Might be interesting to have a little test code or something from somebody which uses webstart and works fine. The rest I will find out myself then .. really can't see the problem. I litterly tried the method from the tutorial at the Java Games Factory, but nothing. He can't find it in the JNLP classloader .. !
Offline DanK

Junior Member




Javver games rock yawel!


« Reply #19 - Posted 2004-06-14 08:17:43 »

I looked at your files and everything looks fine, all I can say is are you absolutely sure that your jar file contains the latest version of your class files? Your code looks correct and your jar looks correct (as far as I know, I'm new to webstart myself). I'd say start over from scratch on your jar file, delete the old one, and re-add everything and sign it. I looked through your source and jar files but actually compiling your code is one step past where I'm willing to go tonight :p

Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #20 - Posted 2004-06-14 08:32:55 »

thanx .. will take a look at it tonight then !
Offline Guoshima

Junior Member




Java games rock! Do they .. ?


« Reply #21 - Posted 2004-06-14 19:59:51 »

well I tried it, and gives nothing. I already tried to put all my classes in a new package, because now it was in a default package. Already tried the the SystemClassLoader .. still nothing. I really don't see what I am doing wrong here ! Is there nowhere a decent webstart tutorial or so ?!?
Offline pdjensen

Senior Newbie





« Reply #22 - Posted 2004-06-14 21:49:40 »

I'm not sure this is the problem you are chasing, but...

When I run:

   http://users.pandora.be/kozen/demos/Sample.jnlp

I get an error from JWS that indicates you have not signed Sample.jar and the jogl*.jar files with the same key:

An error occurred while launching/running the application.

Title: JOGL Sample
Vendor: K. Development
Category: Security Error

Unsigned application requesting unrestricted access to system
Unsigned resource: http://users.pandora.be/kozen/demos/Resources/jogl-natives-macosx.jar
Offline ribot

Junior Member




Ribot - mobile UI specialist


« Reply #23 - Posted 2004-06-14 23:35:42 »

Clicking that last JNLP link, I get an error that the server is not currently available.

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Pages: [1]
  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.

pw (35 views)
2014-07-24 01:59:36

Riven (34 views)
2014-07-23 21:16:32

Riven (22 views)
2014-07-23 21:07:15

Riven (25 views)
2014-07-23 20:56:16

ctomni231 (56 views)
2014-07-18 06:55:21

Zero Volt (48 views)
2014-07-17 23:47:54

danieldean (39 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!