title: Finding the classpath of a web app
body: <p>When I'm working on my web app in Eclipse, I can search all the classes and JAR files with</p>
  
  <pre><code>String cp = System.getProperty("java.class.path");
  </code></pre>
  
  <p>but when I deploy on Tomcat or Jetty, I get nothing.</p>
  
  <p>I want to find all <code>*.properties</code> files which are located in the webapp (either in the JAR or, if exploded, in folders).</p>
  
  <pre><code>String cp = System.getProperty("java.class.path");
  String pathSep = File.pathSeparator;
  String[] jarOrDirectories = cp.split(pathSep);
  for (String fileName : jarOrDirectories) {
          File file = new File(fileName);
          if (file.isFile()) {
                  logger.debug("From jar "+file.getName());
                  loadFromJar(file.getPath());
          } else {
                  logger.debug("From folder "+file.getName());
                  listFolder(file);
          }
  }
  </code></pre>
  
  <p>This way, running the web application in Eclipse gives me all JAR files and all class folders, but not when I deploy the application in Tomcat.</p>
  
  <p>It would be enough if I could just get the path to <code>WEB_INF</code>. From there, it's easy.</p>