1

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?

Zharro
  • 819
  • 1
  • 11
  • 23

1 Answers1

1

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")
Mikita Belahlazau
  • 15,326
  • 2
  • 38
  • 43