简体   繁体   English

Java ResourceBundle.getBundle缺少资源异常

[英]Java ResourceBundle.getBundle missing resource exception

I'm new to Java and have taken some old java code and tried to get it running in the latest version of Eclipse. 我是Java的新手,并使用了一些旧的Java代码,并尝试使其在最新版本的Eclipse中运行。

The code compiles but when I run it I receive an error. 代码可以编译,但是当我运行它时,我收到一个错误。

This is the line of code that is causing the error: 这是导致错误的代码行:

ResourceBundle properties = ResourceBundle.getBundle("resources/system");

And the error I receive is this: 我收到的错误是这样的:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.util.MissingResourceException: Can't find bundle for base name resources/system, locale en_GB
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
at com.tma.sp.flowvalidator.ThreadLauncher.<clinit>(ThreadLauncher.java:28)

I've searched about a bit for this error but every answer seems different. 我已经搜索了一下此错误,但每个答案似乎都不同。

Is there a simple fix for this? 有一个简单的解决方案吗?

 ResourceBundle properties = ResourceBundle.getBundle("resources/system"); 

The path given is relative to the package of the calling class. 给定的路径是相对于调用类的包的。 You need to specify an absolute path (by means of UNC-Path) by preceding a slash: 您需要在斜杠前指定绝对路径(通过UNC-Path):

ResourceBundle properties = ResourceBundle.getBundle("/resources/system");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM