/**
* 查找XXXX.class的真实使用路径 (应对那种找不到正确依赖class的问题)
*/
try
{
// 取得class文件对应保护域
java.security.ProtectionDomain ptdm = ByteBuffer.class
.getProtectionDomain();
java.security.CodeSource csc = ptdm.getCodeSource();
java.net.URL loc = csc.getLocation();
String realLoc = URLDecoder.decode(loc.getFile(), "UTF-8");
System.err.println("ptdm =" + ptdm);
System.err.println("csc =" + csc);
System.err.println("loc =" + loc);
System.err.println("realLoc =" + realLoc);
/* ptdm =ProtectionDomain (file:/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip <no signer certificates>)
sun.misc.Launcher$ExtClassLoader@288d539f
<no principals>
java.security.Permissions@57f6eb51 (
("java.io.FilePermission" "/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip" "read")
)
csc =(file:/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip <no signer certificates>)
loc =file:/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip
realLoc =/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip*/
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
} /**
* 查找XXXX.class的真实使用路径 (应对那种找不到正确依赖class的问题)
*/
try
{
// 取得class文件对应保护域
java.security.ProtectionDomain ptdm = ByteBuffer.class
.getProtectionDomain();
java.security.CodeSource csc = ptdm.getCodeSource();
java.net.URL loc = csc.getLocation();
String realLoc = URLDecoder.decode(loc.getFile(), "UTF-8");
System.err.println("ptdm =" + ptdm);
System.err.println("csc =" + csc);
System.err.println("loc =" + loc);
System.err.println("realLoc =" + realLoc);
/* ptdm =ProtectionDomain (file:/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip <no signer certificates>)
sun.misc.Launcher$ExtClassLoader@288d539f
<no principals>
java.security.Permissions@57f6eb51 (
("java.io.FilePermission" "/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip" "read")
)
csc =(file:/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip <no signer certificates>)
loc =file:/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip
realLoc =/home/shuma_xiyougo/shumajava/jre/lib/ext/xln.zip*/
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
查找XXXX.class的真实使用路径 (应对那种找不到正确依赖class的问题)
最新推荐文章于 2023-04-12 20:25:49 发布