I don't seem to be reading external file from jar when on linux

The following code works fine on windows:

private static Properties getProps() throws FileNotFoundException, IOException {
    Properties properties = new Properties();
    File externalFile = new File("myProp.properties");

    if(externalFile.exists()) //if an external property file exists within the same path it is prioritized
        properties.load(new FileInputStream(externalFile));
    else{
        properties.load(CommandUtil.class.getClass().getResourceAsStream("/com/localpath/default.properties"));
    }
    return properties;
}

      

if myProp.properties exists in the same .jar folder then this property file is read, otherwise the default .properties file contained within the .jar itself will be executed.

When I move this program on a Linux system it doesn't work anymore: even if there is a .properties file next to the .jar, it is simply ignored. Why is this?

+3
java linux


source to share


No one has answered this question yet

Check out similar questions:

4800
How do I find all files containing specific text in Linux?
1773
How to symbolize a file in Linux?
1376
How to create Java string from file content?
1101
How to copy a folder with files to another folder in Unix / Linux?
1011
How do I add local jar files to a Maven project?
851
Reading a text file in Java
838
Unable to execute jar file: "no main manifest attribute"
596
Recursively count files in a Linux directory
442
Correct way to add external jars (lib / *. Jar) to IntelliJ IDEA project
0
Could not read properties file from resource folder



All Articles
Loading...
X
Show
Funny
Dev
Pics