.properties file is not searched by jar when it is

2019-09-06 04:36发布

问题:

When I run the jar on cmd it do not search the .properties file and hence the complete functionality is not established. My .properties file is under the /src folder. How can I resolve this issue?

try {
    // Loads the constants.properties file
        InputStream constantPropFile = 
            ClassLoader.class.getResourceAsStream
 ("/account.properties");
        constantProp.load(constantPropFile);
    }  catch (IOException e) {
    // TODO Auto-generated catch block
        e.printStackTrace();
    }
标签: java jar cmd