I'm creating a plugin to de reflected and call by main application. This plugin uses xml file and I want to make it embedded resource. I build plugin as artifact (JAR). My actions:
1) Put xml file to directory 'trunk/res' configured as 'source root'
;
2) Performed 'make module'
action for the module in which directory 'trunk/res' is;
3) Into the plugin I access xml file through file path dom = db.parse("trunk//res//resource.xml");
But when I call plugin from the main application I get this exception about system cannot find the file 'MainApp/trunk/trunk/res/resource.xml'
. I guess I don't extract resource properly, but how to do it correctly?
Try to call:
System.out.println(getClass().getProtectionDomain().getCodeSource().getLocation());
And see if you're really calling from jar. And then
InputStream xmlFileStream = getClass().getClassloader().getResourceAsStream("res\\AIP_82.xml")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.