The Source for Java Technology Collaboration

Home » java.net Forums » Java Deployment & Distribution » Java Web Start

Thread: Support for files outside jars

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 6 - Last Post: May 14, 2007 3:24 PM by: tdanecito Threads: [ Previous | Next ]
tdanecito

Posts: 379
Support for files outside jars
Posted: May 2, 2007 11:08 AM
  Click to reply to this thread Reply

Hi All,

Does anyone know how to get webstart to put files outside the jar in a temp location that is related to where the jnlp starts from? I have a open source project whose code looks for files relative to the location of where the web start application starts. I discovered if I copy the files to the expected file on the desktop then everything is okay.

What I would like to do is put the files (dll's actually) in a location that can be found by the app but not visible on the dektop.

Any ideas? I figured maybe to use the user.home path and create a temp dir there then copy the dlls there for the open source code to find. Hate to put it in one users folder rather than a centralized temp folde but not sure how to go about that.

Regards,
-Tony

twalljava

Posts: 94
Re: Support for files outside jars
Posted: May 2, 2007 8:59 PM   in response to: tdanecito
  Click to reply to this thread Reply

The recommended way of delivering native shared libraries via JWS is to put them in the root of a jar.

Of course, if you're not loading via System.loadLibrary, you'll have to figure out the actual location, but JWS will at least download and install them for you.

Chances are you could obtain the dll path via ClassLoader.getResource.

mthornton

Posts: 528
Re: Support for files outside jars
Posted: May 3, 2007 8:54 AM   in response to: twalljava
  Click to reply to this thread Reply

> Chances are you could obtain the dll path via
> ClassLoader.getResource.
I understand, that as of JDK 6, that ClassLoader.getResource will return the location on the site from which the resource was obtained and not the location on your machine.

sauvage

Posts: 65
Re: Support for files outside jars
Posted: May 3, 2007 5:40 AM   in response to: tdanecito
  Click to reply to this thread Reply

Hi,

It is possible to load a dll using the nativelib tag in JNLP file as mentioned in the Java Web Start FAQ: http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/faq.html#210.
With this kind of deployment the dll is located in Java Web Start cache and is not visible in the desktop. Then use System.loadLibrary() with the library name without .dll extension.
If you are not the owner of the code loading the library and cannot make it work the proper way, consider using System.setProperty("java.library.path", "apath") to set the path where dlls are located.

Reagards,

Laurent.

evickroy

Posts: 674
Re: Support for files outside jars
Posted: May 3, 2007 7:56 AM   in response to: sauvage
  Click to reply to this thread Reply

Like Laurent said...

Here's a sample snippet from a JNLP file that uses JDIC components that requires native libs:

<resources os="Windows">
	<jar href="jdic.jar" version="0.5.1"/>
	<nativelib href="jdic-native.jar" version="0.5.1"/>
</resources>




Erik

luano

Posts: 122
Re: Support for files outside jars
Posted: May 3, 2007 11:40 AM   in response to: tdanecito
  Click to reply to this thread Reply

If you need to store files locally you can use the JNLP PeristenceService API, see:

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/jnlp/javax/jnlp/PersistenceService.html

And as other have mentioned JWS already includes support for loading native libraries. However there are still cases where that isn't enough, for example where the DLL needs to read files from the filesystem. Another option is to store the files under the user's profile (in their temp folder). The XUI project has a LibraryLoader class for this purpose, see:

http://xui.svn.sourceforge.net/viewvc/xui/xui/branches/xui3/src/net/xoetrope/os/

tdanecito

Posts: 379
Re: Support for files outside jars
Posted: May 14, 2007 3:24 PM   in response to: tdanecito
  Click to reply to this thread Reply

Thanks everyone,

I ended up writing code to extract the dlls and put them in a specific directory where the dll's could locate themselves. I know quite well the native lib mechanism for dlls but this was a different case where the main dll wanted the absolute location of the others for dynamic linking.

So I am running fine now.
Thanks,
-Tony




 XML java.net RSS