PulsePanda
PulsePanda

Reputation: 1856

Java not finding .property file Ubuntu

I have a game that loads a .properties file. the name of the file is properties.properties. when i run the game in windows, it works, but when i load it in Linux (Ubuntu) it throws the fileNotFoundException. the running .jar and property file are in the same folder, and i'm calling the property file using:

currentProp = new Properties();
    try {
        currentProp
                .load(new FileInputStream(
                        "../bin/properties.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }

and have even tried:

currentProp = new Properties();
    try {
        currentProp
                .load(new FileInputStream(
                        "properties.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }

along with

currentProp = new Properties();
    try {
        currentProp
                .load(new FileInputStream(
                        "../properties.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }

i'm not exactly sure why it isnt working, but when i run it with: java -jar ~/Desktop/Files/bin/NPS.jar in the Linux terminal, i get the error:

java.io.FileNotFoundException: ../bin/properties.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at main.Start.loadProperties(Start.java:56)
at main.Start.main(Start.java:34)
    Exception in thread "main" java.lang.NullPointerException
at main.Start.main(Start.java:36)

and i have no clue as to why! it is mildly frustrating.... because it works just fine in windows.

Upvotes: 1

Views: 1430

Answers (1)

Jiri Kremser
Jiri Kremser

Reputation: 12837

instead of java -jar ~/Desktop/Files/bin/NPS.jar try cd ~/Desktop/Files/bin/ && java -jar NPS.jar

Upvotes: 4

Related Questions