How to distinguish 32 bit from 64 bit java version in jnlp files

Dave picture Dave · Feb 1, 2013 · Viewed 8.5k times · Source

To start our legacy application, we use java WebStart via a jnlp.

We would like to support 64-bit Java clients but one of our libraries is architecture dependent.

We thought of doing something like:

<resources>
  <j2se version="1.6+" sun.arch.data.model="64"/>
  <jar href="/apps/swt-3.7M5-win32-win32-x86_64_s.jar" download="eager" />
</resources>
<resources>
  <j2se version="1.6+" />
  <jar href="/apps/swt-3.7M5-win32-win32-x86_s.jar" download="eager" />
</resources>

This is not working because the parameter sun.arch.data.model="64" is used to set the parameter instead of testing on it.

Any ideas?

Answer

Dr.Haribo picture Dr.Haribo · Feb 2, 2013

This is explained in the documentation, here: http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/syntax.html#resources

It doesn't say which arch values make sense, though. You would want it to work for different JVM implementations and versions. I googled around for a while and here's what I've ended up using:

  <resources>
    <java version="1.6+"/>
    <jar href="lwjgl-2.8.4.jar"/>
    <jar href="lwjgl_util-2.8.4.jar"/>
  </resources>

  <!-- LWJGL Linux 64-bit native libraries -->
  <resources os="Linux" arch="amd64">
    <nativelib href="lwjgl-amd64-linux.jar"/>
  </resources>
  <resources os="Linux" arch="x86_64">
    <nativelib href="lwjgl-amd64-linux.jar"/>
  </resources>

  <!-- LWJGL Linux 32-bit native libraries -->
  <resources os="Linux" arch="x86">
    <nativelib href="lwjgl-x86-linux.jar"/>
  </resources>
  <resources os="Linux" arch="i386">
    <nativelib href="lwjgl-x86-linux.jar"/>
  </resources>

  <!-- LWJGL Windows 64-bit native libraries -->
  <resources os="Windows" arch="amd64">
    <nativelib href="lwjgl-amd64-win.jar"/>
  </resources>
  <resources os="Windows" arch="x86_64">
    <nativelib href="lwjgl-amd64-win.jar"/>
  </resources>

  <!-- LWJGL Windows 32-bit native libraries -->
  <resources os="Windows" arch="x86">
    <nativelib href="lwjgl-x86-win.jar"/>
  </resources>
  <resources os="Windows" arch="i386">
    <nativelib href="lwjgl-x86-win.jar"/>
  </resources>

  <!-- LWJGL MAC OS/X native libraries -->
  <resources os="Mac">
    <nativelib href="lwjgl-macosx.jar"/>
  </resources>