Java 运行eclipse项目时引发bundle not found异常
为什么保存后的属性文件在eclipse项目中显示为.properties.txt。我已将该文件放在包的src文件夹中,但仍会为未找到的包引发异常Java 运行eclipse项目时引发bundle not found异常,java,Java,为什么保存后的属性文件在eclipse项目中显示为.properties.txt。我已将该文件放在包的src文件夹中,但仍会为未找到的包引发异常 package array; import java.util.*; public class AddingToList { static public void main(String[] args) { String language; String country; if (args.length != 2) {
package array;
import java.util.*;
public class AddingToList {
static public void main(String[] args) {
String language;
String country;
if (args.length != 2) {
language = new String("en");
country = new String("US");
} else {
language = new String(args[0]);
country = new String(args[1]);
}
Locale currentLocale;
ResourceBundle messages;
currentLocale = new Locale(language, country);
messages = ResourceBundle.getBundle("MessagesBundle", currentLocale);
System.out.println(messages.getString("greetings"));
System.out.println(messages.getString("inquiry"));
System.out.println(messages.getString("farewell"));
}
}从评论到回答,再到接受:
消息包必须在“默认包”中+对包的调用应该是
“/MessagesBundle”
从eclipse重命名文件并从末尾删除.txt。不需要重命名,您如何尝试检索资源?它应该包含/package/。/subpackage/resource
@R.J..没有显示重命名选项。@antoniosss..我没有制作任何子包,而是将它们复制到我的包文件夹中。我正试图通过基地访问他们name@R.J...renaming工作正常,但程序仍显示异常。我正在这里粘贴代码。属性文件名为MessageBundle。