String resourceName = "/log4j.xml"; // pay attention to the leading '/' ! URL location = AnyClass.class.getResource(resourceName); if (location != null) { System.out.println(location.getPath()); } else { System.out.println(resourceName + " not found on the classpath"); }
You need to create an account or log in to post comments to this site.