一些路径问题:
一、Jboss conf 目录下的路径
Properties props = System.getProperties();
String filePathUrl = props.getProperty("jboss.server.config.url");
// filePathUrl = file:/D:/Infor/wm/jboss-4.2.3.GA/server/wmprd-wmapp1/conf/
String filePath = filePathUrl.substring(filePathUrl.indexOf("/")+1)+"wmsconfig.properties";
// filePath = D:/Infor/wm/jboss-4.2.3.GA/server/wmprd-wmapp1/conf/wmsconfig.properties
Properties JMS_PROP = new Properties();
JMS_PROP.load(new FileInputStream(filePath));
String tcp = String.valueOf(JMS_PROP.get("jms.tcp"));
二、类路径 classpath
1. String path = Thread.currentThread().getContextClassLoader().getResource("").getPath()+"wmsconfig.properties";
2. String path = 类名.class.getClassLoader().getResource("").getPath()+ "wmsconfig.properties";
path = "/D:/Infor/wm/jboss-4.2.3.GA/server/default/deploy/wms.war/WEB-INF/classes/wmsconfig.properties"
System.getProperty("user.dir") // D:/Program Files/apache-tomcat-6.0.20/bin