Changed Resource Loading in Java Webstart JDK 1.5.0_16?

Discussion in 'Java' started by Andi, Jul 28, 2008.

  1. Andi

    Andi Guest

    Hi,

    I have a small webstart application. I am loading a xml file from a
    jar file.

    URL url = Program.class.getResource("/xml/settings.xml");

    In Java Webstart of JDK 1.5.0_15 and JDK 1.6.0_7 I got following URL:

    jar:file:[Path to jar file]!/xml/settings.xml

    In JDK 1.5.0_16 I got

    jar:xml/settings.xml

    Does anybody knoes why that was changed. I have problems with this url
    when I try to use a Xerces parser.

    Thanks
    Andi, Jul 28, 2008
    #1
    1. Advertising

  2. On Jul 28, 7:51 pm, Andi <> wrote:
    > Hi,
    >
    > I have a small webstart application. I am loading a xml file from a
    > jar file.
    >
    > URL url = Program.class.getResource("/xml/settings.xml");


    Try it this way..

    .. = Thread.
    currentThread().
    getContextClassLoader().
    getResource("/xml/settings.xml");

    --
    Andrew Thompson
    http://pscode.org/
    Andrew Thompson, Jul 28, 2008
    #2
    1. Advertising

  3. Andi

    Andi Guest

    > Try it this way..
    >
    > .. = Thread.
    >   currentThread().
    >   getContextClassLoader().
    >   getResource("/xml/settings.xml");


    Then I get null for the url.
    Andi, Jul 28, 2008
    #3
  4. On Jul 28, 7:51 pm, Andi <> wrote:
    ...
    > Does anybody knoes why that was changed.


    I saw a slew of links related to this general problem,
    based on a post by sunnychangs to zai in
    'jnlp java version specification 1.6.0_02 not working'
    <http://forums.sun.com/thread.jspa?threadID=5318200>.

    The word 'this' in the first sentence links to an
    Eclipse bug report that links back to or mentions
    a number of closely related (Sun) bug reports.

    The upshot is that.. *Sun will no longer provide
    the path to the Java cache.*

    > ..I have problems with this url when I try to use a Xerces parser.


    One suggestion might be ..
    - obtain the bytes from an input stream from the cached jar
    - write the bytes to a temporary file
    - ..and use that temporary file for the URL to the parser.

    Note that others* have already expressed doubt in the
    'temporaryness' of any files created.

    * I think the Eclipse thread has a similar problem/solution
    check the docs, read the thread..

    --
    Andrew Thompson
    http://pscode.org/
    Andrew Thompson, Aug 4, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Thompson

    Re: Webstart & Loading ImageIcons?

    Andrew Thompson, Jul 7, 2003, in forum: Java
    Replies:
    0
    Views:
    415
    Andrew Thompson
    Jul 7, 2003
  2. Babar
    Replies:
    1
    Views:
    431
    Chris Smith
    May 20, 2004
  3. Replies:
    0
    Views:
    1,054
  4. Replies:
    2
    Views:
    353
    Richard Maher
    Mar 8, 2008
  5. Roedy Green
    Replies:
    0
    Views:
    628
    Roedy Green
    Aug 11, 2009
Loading...

Share This Page