Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 运行eclipse项目时引发bundle not found异常_Java - Fatal编程技术网

Java 运行eclipse项目时引发bundle not found异常

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) {

为什么保存后的属性文件在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) {
        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。