0 Replies Latest reply on Dec 23, 2002 6:33 PM by Shane Ye

    help - can't locate resource file using relative path

    Shane Ye Newbie

      Hi,

      Did anyone ever try this?
      I am using jboss-3.0.4_tomcat-4.1.12
      What I am trying to do is to read txt/xml files in Java class by providing a relative path. I try to obtain the URL for the resource file first, then instantiate the File(it can be a directory too) using that URL.
      When I use absolute path, everything works great:
      see code below:('sql' is a folder holding resource files)
      <<<<<<<<
      Resources.class.getClassLoader().getResource("/home/shane/
      jboss-3.0.4_tomcat-4.1.12/server/default/lib/sql/");
      >>>>>>>>

      but since this code will need to be put into CVS, it's better to use a relative path instead of an absolute one.
      when I modified the code to as below, it can't obtain the URL anymore, it just thinks the folder sql doesn't exist user '/home/shane/
      jboss-3.0.4_tomcat-4.1.12/server/default/lib/', but I believe this should be the application path for libraries.

      <<<<<<<<
      Resources.class.getClassLoader().getResource("sql/");
      >>>>>>>>

      Not sure why, but it worked this way in JBOSS 2.4.6.

      Any ideas?


      Thanks -Shane