facebook

JAR’s and loading

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #239233 Reply

    gcormier
    Member

    Hi. Havin some general java problems 😉

    I have a Project say “HelloWorld”. It uses, let’s say, Poems.jar. Inside poems.jar we have

    test.poems.FunPoems.xml

    I want to load this XML file inside of HelloWorld. Trying a simple loading of resource gives “Resource not found”.

    Do I have to do some fancy dynamic-class loading stuff? 😐 I’m assuming resource loads check the actual path of your project, but they won’t look in the JAR files like it would for a .class file? Any ideas?

    Thanks,
    Greg

    #239340 Reply

    Riyad Kalla
    Member

    Greg,
    I know I’ve needed to refer to some docs when trying to do this in the past, best bet is Dr. Google: http://www.google.com/search?hl=en&q=loading+XML+from+JAR+file&btnG=Google+Search

    #239343 Reply

    gcormier
    Member

    🙂 I came across the same pages last night while googling 😛

    What I end up doing is putting a dummy class inside that JAR.

    Then I lookup that class, and get their class loader, and call a get Resource.. and it works! I almost fell out of my chair when it happened.

    To me though… Java shouldn’t be like this… it’s part of that classpath hell I suppose.

    #239350 Reply

    Riyad Kalla
    Member

    Did you try jar-specific paths like: getResource(“jar!//com/test/blarg.xml”)

    I think that format is right, you may need to double check me.

    #239351 Reply

    gcormier
    Member

    Ahh, I remember seeing something like that too, I’ll have to give it a try for my notes 🙂 I guess it is a bit cleaner.

    #239362 Reply

    Riyad Kalla
    Member

    Did you try posting to http://forums.java.sun.com, it’s a very handy resource at times… and the way you did it while very inventive, I sure hope to god isn’t the “suggested” way to do what you are trying to do.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: JAR’s and loading

You must be logged in to post in the forum log in