How to reference directories correctly when launching a .jar from a batch file?
I am trying to launch a jar file from a .bat . One of the first things my code does is open and read from a file. I reference the file like this:
final ArrayList<EmailAccount> emailList = FileIO.getListOfAccountsFromFile(".\\EmailList\\list.txt");
Everything works fine if the batch file is in the same directory as my jar. HOWEVER, if I put my batch file somewhere else and try to run it (like i plan to have it work), the program thinks that I'm trying to reference a file that is in the
".bat directory"\EmailList\list.txt
instead of
".jar directory"\EmailList\list.txt
and comes up with a fileNotFoundException.
Is there any way that I can run my batch file from a different directory while correctly referencing files in relation to the jar without hard coding in the jar's file path?