ffyahoo 发表于 2013-2-3 14:41:59

动态获取打包Jar后的路径信息

打包后的java文件已经在jar包里面,如何获取路径信息呢?
 
 
 
String path = null;String jarPath = MyDataSource.class.getProtectionDomain()      .getCodeSource().getLocation().getPath();try {path = URLDecoder.decode(jarPath, "UTF-8").replaceAll("client.jar", "").replaceAll("%20", " ");} catch (UnsupportedEncodingException e) {log.error(e.getMessage());}log.info("path is:"+path);  
 
  client.jar为打包的jar名
页: [1]
查看完整版本: 动态获取打包Jar后的路径信息