12/10/2001 10:38:05 PM, [EMAIL PROTECTED] wrote:
>
>I think Oliver Hoffmann wrote:
>[Charset iso-8859-1 unsupported, filtering to ASCII...]
>> Ernest (and anyone else interested) ...
>>
>> if (u == null)
>> u = Thread.currentThread().getContextClassLoader().getResource(filename);
>> if (u == null)
>> throw new JessException("batch", "Cannot open file", e);
>
>Interesting. Why, in general, does
>getContextClassLoader().getResource() return
>something different than getClass().getResource()?
I took that from
http://java.sun.com/products/javawebstart/docs/developersguide.html
"Java Web Start only transfers JAR files from the Web server to the client machine. It
determines where to store the JAR files on the local machine. Thus, an application
cannot use disk-relative references to
resources such as images and configuration files.
All application resources must be retrieved from the JAR files specified in the
resources section of the JNLP file, or retrieved explicitly using an HTTP request to
the Web server. We recommend storing resources in
JAR files, since they will be cached on the local machine by Java Web Start.
The following code example shows how to retrieve images from a JAR file:
// Get current classloader
ClassLoader cl = this.getClass().getClassLoader();
// Create icons
Icon saveIcon = new ImageIcon(cl.getResource("images/save.gif"));
Icon cutIcon = new ImageIcon(cl.getResource("images/cut.gif"));"
and
http://java.sun.com/products/javawebstart/faq.html
"How can I load resources within my application using Class.forName and
ClassLoader.getSystemClassLoader in JavaTM Web Start?
JavaTM Web Start uses a user-level classloader to load all the application resources
specified in the JNLP file. This classloader implements the security model and the
downloading model defined by the JNLP
specification. This is no different than how the AppletViewer or the Java Plug-In
works.
This has the, unfortunate, side-effect that Class.forName will not find any resources
that are defined in the JNLP file. The same is true for looking up resources and
classes using the system class loader
(ClassLoader.getSystemClassLoader).
To find application resources in JavaTM Web Start, make sure to use the classloader
that loaded your application, e.g.,:
this.getClass().getClassLoader(), or
Thread.getCurrent().getContextClassLoader()
Also ensure that the above happens in the main thread."
and just played around with the options ;)
> Is it just that Class.getResource() massages the arguments?
no idea, I used what worked
>Can you get Jess to work
>as-is by just reading the docs for Class.getResource() and tweaking
>the path you're using for the .clp file?
Yes.
If you put all the clp files into the directory you will be in when java web start is
launched (which might be the browsers home directory or the place where java web start
puts its offline-launcher) then JESS works as-
is (signed, of course)
>I wonder if Thread.getContextClassLoader() returns null sometimes,
>just as Class.getClassLoader() is allowed to do; if so this code needs
>to check for that. The Javadoc aren't clear on what happens if
>Class.getClassLoader() returns null.
I will check that
:) Oliver Hoffmann
>---------------------------------------------------------
>Ernest Friedman-Hill
>Distributed Systems Research Phone: (925) 294-2154
>Sandia National Labs FAX: (925) 294-2234
>Org. 8920, MS 9012 [EMAIL PROTECTED]
>PO Box 969 http://herzberg.ca.sandia.gov
>Livermore, CA 94550
>
>--------------------------------------------------------------------
>To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
>in the BODY of a message to [EMAIL PROTECTED], NOT to the list
>(use your own address!) List problems? Notify [EMAIL PROTECTED]
>--------------------------------------------------------------------
>
>
>
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------