Java Web Start and Jogl...

When my Application.jar is being started with Java Web Start, it can’t load the jogl native binding (jogl.dll in the case of Windows, for example). Web Start says:

no jogl in java.library.path

However, if the same Application.jar ist put next to the jogl.dll on a local filesystem, a double click on Application.jar works fine as expected. (Because the java.library.path contains “.” on Windows I suppose).

Of course my .jnlp file contains a native resource elements containing the jogl bins for the various platforms. When I look into the Java Web Start cache folder I see the jogl-native-xyz.jar which has been decompressed to another folder (containing the jogl.dll then).

What do I have to change so that Web Start works fine?

Sounds like you got all the elements right… have you got the webstart somewhere so we could take a look?

Kev

+[quote]Sounds like you got all the elements right… have you got the webstart somewhere so we could take a look?
[/quote]
Yes, it looks like this:


<?xml version="1.0" encoding="utf-8"?>
<jnlp
  spec="1.0+"
  codebase="http://www.xx.yy/user/Webstart/"
  // href="Name.jnlp">
  <information>
    <title>Name</title>
    <vendor>Me</vendor>
    <description>Well</description>
    <offline-allowed/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <resources>
    <j2se version="1.4+"/>
    <jar href="App.jar" main="true"/>
  </resources>
  <application-desc />
  <resources os="Linux">
    <nativelib href="jogl-linux.jar"/>
  </resources>
  <resources os="Windows">
    <nativelib href="jogl-windows.jar"/>
  </resource>
  <resources os="Mac OS X">
    <nativelib href="jogl-macos.jar"/>
  </resources>
  <resources os="SunOS" arch="sparc">
    <nativelib href="jogl-solaris.jar"/>
  </resource>
</jnlp>

The native JARs contain the .dll / .so / etc files, are signed and all that, like the rest.

Java Web Start’s cache folder contains:


.....\P80\DMuser\DMWebstart\RCApp.jar
.....\P80\DMuser\DMWebstart\RNjogl-windows.jar\jogl.dll

Do you do some “magic” inside your main() method of the JAR? Like to include another path to the java.library.path or such?

Nope, Webstart’s class loader works out where the libraries are. If they’re packaged properly loadLibrary() should just work ™.

Kev

What with my game having similar problems, i’m wondering if i’m using the resource tag correctly. I keep seeing different strings used (such as os=“Mac OS X” or os=“MacOS”). Is there a list of ‘proper’ OS strings to load native libraries with?

I found an unofficial webstart FAQ: http://www.vamphq.com/jwsfaq.html#os
That seems to list the acceptable values.

Kev: Judging by this list I think the Solaris and Mac resource tags in your tutorial (and so probably in Martian Madness and S-Type) need changing.

Check the JNLP of the webstart demos on the JOGL project page. They work for me.

As for names like “Mac OS X” these strings must match what the system property “os.name” returns… For Mac OS X this is the string “Mac OS X”… I think you only have to match as many characters as you provide… e.g. .startsWith(blah). so for all versions of windows you can say “Windows” and it will match “Windows 2000” “Windows XP”, etc.

For resource loading and other issues see http://java.sun.com/products/javawebstart/faq.html

Yes, i noticed the partial matching thing, which is why just using “Windows” works. However i’ve been using one based off of Kev’s tutorial which has os=“MacOS” (without the space).

Solaris aside, I’ve updated my SType ones with a proper “Mac OS” resource tag now, perhaps that’ll fix some issues.

I’ll update the tutorial again… however, the MacOS tag does work, although from the explanation above… I don’t know why :slight_smile:

EDIT: Tutorial updated.

Kev

Ok, thanks again. There are some pitfalls with Web Start…
I’ve changed the OS strings. The jogl.dll does also work now. No idea why it didn’t before, but well, it’s OK now.
Like Kev said: “however, the MacOS tag does work, although from the explanation above… I don’t know why”. Looks like we all don’t know what Web start does exactly. :wink:

PS: [quote]should just work ™.
[/quote]
ROFL :slight_smile:

Unfortunately for my free space Web site I can’t change the MIME types. So if http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/setup.html suggests: “Configure the Web server so that all files with the .jnlp file extension are set to the application/x-java-jnlp-file MIME type.” , this doesn’t work for me.

Still, with some browsers (Opera) it’s possible to click the .jnlp file on my site and everything works. On another PC with another browser (Mozilla I think) and another JRE the .jnlp file is being started but then Web Start stops with errors (“invalid Xml tags” or such).

Is there anything I can do so that it always works? Creating a Java Script? … :frowning:

You can get round this a couple of ways…

I think the vampHQ faq talks about these (its linked above).

My howto (http://www.cokeandcode.com/info/webstart-howto.html) also covers a couple of them.

Kev

[quote]You can get round this a couple of ways…

I think the vampHQ faq talks about these (its linked above).

My howto (http://www.cokeandcode.com/info/webstart-howto.html) also covers a couple of them.
[/quote]
Hi Kev, thanks a lot. On the vampHQ I didn’t find the MIME problem being explained (bit a lot of other things), however PHP thing of your nice and short Howto does do the trick.
I’ve added the two lines and renamed the .jnlp to .php and it looks like it works (for me and another PC, too). That would be cool. Have to test further but hey presto. Presto? Preston.

PS: Your Howto’s ClassLoader on static classes is pretty usefull, too.

Say you would like to use this yet unofficial sun.misc.Perf high-res timer (an equivalent one with another name will be there in J2SE 1.5), which is hidden in the J2SE 1.4.2 . Would the following line in the .jnlp do the trick?


<resources>
  <j2se version="1.4.2+"/>
  ...

(How to specify a micro version number is explained here: http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/syntax.html#resources )

Or does “unofficial” mean the high-res timer is just in the Win32 J2SE 1.4.2 but not in the Linux, Mac, … one?

I don’t think that will work. I thought the ‘+’ (‘this version and newer’) could only be used with one dot, like 1.3+ or 1.4+ … but not 1.3.0+
You can use '’ so anything beginning with 1.4.2 is 1.4.2 … which won’t match 1.5, but you could have a separate section in the JNLP that had 1.5+

Sounds like an RFE on the way…? ::slight_smile:

I think the idea is that your code should generally require only a particular major release, but not be so picky about maintenance releases. If it is that picky then you can specify the exact release. I don’t think the mechanism was intended to pick out unsupported details in the sun.* packages, since a release with the same version # does not need to implement unsupported sun.* code.

E.g. the mac version of 1.4.2 may have problems if the hi-res timer is not there, but you see version 1.4.2 and assume it is. It would be better to check if is there by catching the exception if it is missing and fall back to a supported option. (not for every call to use the timer… just once to decide which implementation to assign to your timer interface.)

sorry for not seeing this topic earlier.

I’ve written a small tutorial on the subject and have a good way of taking Kev’s mime-type stuff further so that the files still end in “.jnlp” (by using .htaccess and mod_rewrite).

http://xith.org/tutes/GettingStarted/html/deploying_xith3d_games_with.html

The tutes for Xith3d, for which the JOGL libraries are a subset.

Ignore my OSX string - that’s been fixed for the real demo but not updated in the code (I must do that now).

Will.

[quote]sorry for not seeing this topic earlier.
[/quote]
Such happens to me all the time because of that “view 10 recent postings” limit…
:slight_smile:

The Xith tutorial on Webstart is nice, thank you. I’ve already applied Kev’s PHP trick to my Jnlp file. For some friends this worked then. However there are still some who say it doesn’t work. Somehow even the .php Webstart file isn’t regonized by their browser and they obtain an corrupted .jnlp file with corrupted newlines and so their native Webstart complains about missing tags, etc.
Is there something I can do against this? I’ve to add I’m on one of those free web space providers (they suck, usually, I know)… Would a small example with URL help?