how to add an xml file to the java application's classpath in eclipse?

后端 未结 3 1437
盖世英雄少女心
盖世英雄少女心 2021-02-19 01:02

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

相关标签:
3条回答
  • 2021-02-19 01:46

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

    0 讨论(0)
  • 2021-02-19 01:50

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

    0 讨论(0)
  • 2021-02-19 01:54

    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

    0 讨论(0)
提交回复
热议问题