在创建 jar 文件时将 XML 文件放在 Netbeans 目录结构中的哪个位置

发布于 2024-10-01 17:25:49 字数 270 浏览 1 评论 0原文


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

但我用类创建了 xml 文件的 jar。这个jar与其他一些项目一起使用这次方法无法读取xml文件。

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

In Netbeans IDE i am writing a java class which has some method. One method reads a xml file that I put in the src/resources folder. To access this xml I use the path "src/resources/xmlFile.xml". When I run the class from the ID It works fine. No problem.

But I create the jar of the xml file with the classes. This jar is used with some other project This time method is unable to read the xml file.

What relative path I should use so the method will be able to read the xml? or what other solution could be?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文