17

I need an xml file to be accessed via the classpath in a java application i am creating . how to achieve it in eclipse

user727272
  • 475
  • 2
  • 9
  • 20

3 Answers3

24

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

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
1

Put the directory containing the XML in the runtime classpath, then use className.Class.getResourceAsStream() to get an InputStream containing the XML.

Yoav Kadosh
  • 4,807
  • 4
  • 39
  • 56
Joseph Ottinger
  • 4,911
  • 1
  • 22
  • 23
1

Put it in java source folder, and use it as resource

Imran
  • 2,906
  • 1
  • 19
  • 20