关于java:在jar文件创建中将XML文件放在Netbeans目录结构中

where put the XML file in Netbeans directory structure in jar file creation


在Netbeans IDE中,我正在编写一个具有某些方法的java类。 一种方法读取我放入src / resources文件夹中的xml文件。 要访问此xml,请使用路径" src / resources / xmlFile.xml"。 当我从ID运行类时,它工作正常。 没问题。

但是我用类创建了xml文件的jar。 该jar与其他项目一起使用。此时间方法无法读取xml文件。

我应该使用哪个相对路径,以便该方法能够读取xml? 或者还有其他解决方案?

谢谢


看到这个答案:

在类路径中读取文件