Reputation: 475
I need an xml file to be accessed via the classpath in a java application i am creating . how to achieve it in eclipse
Upvotes: 17
Views: 39460
Reputation: 4951
Put the directory containing the XML in the runtime classpath, then use className.Class.getResourceAsStream()
to get an InputStream containing the XML.
Upvotes: 1
Reputation: 298988
I'd generate a separate resources folder, right-click it and select Build Path > Use as Source Folder
. That way it's on the class path, but you're not mixing it with your Java source files
Upvotes: 24