1 Reply Latest reply: Nov 6, 2009 6:34 PM by 807580 RSS

    Accessing Jar resource issue (in Junit test)


      I have a package called my.test.example containing one class called Example1.class and a property file called MyProp.properties. I am trying to load the content of MyProp.properties with the following:
      static {
          Properties Configuration = new Properties();
          try {
             URL url = Example1.class.getResource("/MyProp.properties");
          } catch (IOException ex) {
              LOG.severe("Cannot load MyProp.properties :\n" + ex.toString());
      The url is systematically null. I have tried including the package name, to use '/' instead of '.', but it does not work. How should I proceed? I am looking for a solution that works wherever the .jar is installed. Is this possible?


      P.S.: I am working under Vista and the static code is invoked in a Junit test. I don't know whether this has an impact on the issue (but I don't think so).