【问题标题】:Can't find resource bundle找不到资源包
【发布时间】:2015-04-13 15:02:22
【问题描述】:

我正在尝试加载属性文件,但我不断收到此错误:

线程“主”java.util.MissingResourceException 中的异常:不能 查找基本名称 D:\bdtej04694\Mis 的捆绑包 文档\NetBeansProjects\SMS_Clientes_Menores\dist\lib\help.properties, 语言环境 es_VE 位于 java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499) 在 java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322) 在 java.util.ResourceBundle.getBundle(ResourceBundle.java:721)

我正在尝试做这个

    private static PropertyResourceBundle slInfo = null;
    //and in another method i'm doing this
    String directory = System.getProperty("user.dir");
            slInfo = (PropertyResourceBundle)ResourceBundle.getBundle(directory+"\\dist\\lib\\help.properties"); 
//I put it on a different folder, just in case i want to make changes in the connection strings inside the properties files, without build the project again in netbeans

我在网上搜索过(很明显,在这个页面上),但我找不到适合我的问题的答案

提前致谢

【问题讨论】:

    标签: java resourcebundle properties-file netbeans-8 missingmethodexception


    【解决方案1】:

    看来你的属性文件路径有问题

    D:\bdtej04694\Mis documentos\NetBeansProjects\SMS_Clientes_Menores\dist\lib\help.properties
    

    尽量避免属性文件路径中的空格,你这里有一个Mis documentos

    关于你的评论:

    像下面这样改变你的路径

    String tempPath =  directory+"\\dist\\lib\\help.properties";
    String finalPath = tempPath.replace("\\", "/");
    

    并使用这个 finalPath

    【讨论】:

    • 是@p27,但是如果你看到了,我用第二条指令得到路径的值,所以我没有“手动”定义路径,所以路径是自动获得的跨度>
    • 尝试在您的最终路径中将 \ 替换为 /。如下所示:D:/bdtej04694/Mis documentos/NetBeansProjects/SMS_Clientes_Menores/dist/lib/help.properties
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多