I'm writing a small app with the help of Eclipse while learning Swing GUIs in Java. I'm also taking my first baby steps in Ant build scripting and have come across a small problem.
I'm parsing an XML file to create objects to store in a List. I've assigned the Ant build script to include the XML file in the Jar package by adding this to the Jar command:
<zipfileset dir="${basedir}" includes="countries.xml" />
To read it I'm doing it through an InputStream
:
InputStream is = getClass().getClassLoader().getResourceAsStream(COUNTRY_XML);
and then parse it with the parse()
-method of a DocumentBuilder
.
To the core of my question, then. After I've run the Ant build script and execute the Jar package, the XML file is easily accessible by the classes and the program runs without problems, but if I only want to test run it in Eclipse (Ctrl+F11) the XML file isn't found, obviously.
Is there a way to remedy this?