B
Blake Essing
I have a simple program that uses a text file for some static data.
When I run my program from within Eclipse or from the jar located in my
workspace it works fine because it can find the path to my development text
file. But I want to be able to run the jar from anywhere. How can I
access the file from within the jar file. Important bits of code I have
are:
private static File mFile = null;
private static String mBaseSolution = "../solution/Solutions.txt";
...
mFile = new File(mBaseSolutions);
if (mFile.exists()) {
...
} else {
System.out.println("Can't find solution file");
System.exit(1);
}
The code fails on the mFile.exists() because it can't find the correct
path.
When I run my program from within Eclipse or from the jar located in my
workspace it works fine because it can find the path to my development text
file. But I want to be able to run the jar from anywhere. How can I
access the file from within the jar file. Important bits of code I have
are:
private static File mFile = null;
private static String mBaseSolution = "../solution/Solutions.txt";
...
mFile = new File(mBaseSolutions);
if (mFile.exists()) {
...
} else {
System.out.println("Can't find solution file");
System.exit(1);
}
The code fails on the mFile.exists() because it can't find the correct
path.