BeanShell 最常用的用法
写好Java代码打成jar, 放到目录\lib\ext下面
package com.test; import java.io.File;
import java.io.UnsupportedEncodingException; public class Common {
public static String getPath(){
String path = Common.class.getProtectionDomain().getCodeSource().getLocation().getFile();
try {
path = java.net.URLDecoder.decode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String jarPath = new File(path).getParentFile().getAbsolutePath();
return jarPath;
}
}