4 Replies Latest reply on Apr 16, 2010 2:57 AM by 843804

    Loading resource from inside jar file?

      Hi all, I am writing a library which is to be packaged as a .jar file. I have resources (text files) inside this jar file. I want classes inside the jar file to be able to load them. I have no problems when I run the jar as a standalone, but when I use this jar as part of another application (specifically I am putting it inside an Eclipse plugin), it does not look for the resource files inside the jar. Instead it tries to look for the resource files inside the Eclipse execution root when I am on Windows and some unknown place when on Linux.

      I have tried:
      Main.class.getResource("res1.txt").getPath() + "\n");
      where 'Main' is the name of my class inside the jar file.

      All three work when doing standalone but not when packaged.