File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JNLP and Web Start and the fly likes Searching for a resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JNLP and Web Start
Bookmark "Searching for a resource" Watch "Searching for a resource" New topic

Searching for a resource

Greg Fidster

Joined: Dec 08, 2004
Posts: 10

I am launching a desktop application via webstart.
One of the features of the application is dynamically creating menu items by searching for a my-plug-in.xml file and grabbing the plugin parameters. Basically the idea is so developers can create their own applications, package them in jars with my-plug-in.xml, and my application will find the plug in file and add their application to the desktop environment.

problem is, i can't find any feature to search through the resources in a webstart launch. the resource loader works fine provided you know the full classpath com/mydomain/app/my-plug-in.xml. if multiple my-plug-in.xml files are packaged without classpath identification, then the loader will just pick the first one.

any solutions? i want a list = getResources("*/my-plug-in.xml") method!

Cristian Negresco
Ranch Hand

Joined: Sep 15, 2001
Posts: 182

One should search through the application jars, list the contents of the jars and find the resources which match the needed pattern. After that the retrieval could be made with getResourceAsStream, or something like that.
Busy now...;0), if problems with any of the steps let us know.

Greg Fidster

Joined: Dec 08, 2004
Posts: 10
Hi Christian,

thanks for the reply. thats what i was doing initially running the application from my desktop, unfortunately it doesn't scale to a webstart launch quite so easily. running from the desktop it's easy to get the current folder or classpath and loop through its contents and grab stuff directly from the jar files. with webstart, the jars are going to be renamed and cached locally in some obscure directory like C:\Documents and Settings\user\Application Data\Sun\Java\Deployment\cache\javaws\http\\P80\DMwebstart\DMapplication, and the classpath will point to something like C:\Program Files\Java\jre1.5.0_02\lib\deploy.jar

i have yet to figure out a method of grabbing a list of all the jar files in the application. i could probably live with grabbing the list of resources from the jnlp file (is there a method for this?), but this doesnt seem like an ideal solution.

D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

I'd create own class loader and access plug-in files directly from server. I have to add a similar functionality to my webstarted application, so please keep us informed what you finally did.

Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
Greg Fidster

Joined: Dec 08, 2004
Posts: 10
I actually did something similar to that.
I merged all the various plug-ins into a single xml file and placed it on the server.

The downside is adds a global file to maintain rather than letting each plug-in manage its own plug-in.xml file. Works fine as an internal applications, but wouldn't fit into a plug-in model such as eclipse.
I agree. Here's the link:
subject: Searching for a resource
It's not a secret anymore!