Bear with me cause I'm new to java and stackoverflow.
Problem: I have a jar that is reading a file from the environment variable of its machine(Server A). If I remote Server A and run this jar, the file reading is ok. But I needed to put this jar and a batchfile to execute it in a SHARED FOLDER to be able to access it without the need to remote Server A.
For the batchfile in the shared folder with "java -jar "%~dp0MYJAR.jar" Adding %~dp0 in front of jar name in batchfile allowed me to call the jar in shared folder. [source in link below]
Can I run a jar file from shared folder of remote system just by double clicking from my system?
But when running the jar, the jar was not able to locate the file its reading in Server A. Here's the code on reading the file.
Properties prop2 = new Properties();
String propFile=System.getenv("OTHERS_HOME") + "\\conf\\FILE_TO_READ.txt";
upon printing the current directory when the jar is running. When remote access to Server A i got E:\ISO_Tester. This is the correct path.
But when running in my machine from a shared folder of Server A i got C:\Windows which I think is from my local machine instead of Server A.