Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA always read the directory from where jar is executed

I have a small java app that updates files in a set location. the app reads from a UpdateFiles folder, moves the files in this folder to the appropriate folder. the app works. what i want to know is how should i set my path if i want the app to always try and look for the UpdateFiles folder in same location that the app is? for example if the app is executed from desktop i want it to look for the UpdateFiles folder in desktop, same for any other location. The app runs on windows and AIX/linux enviroments

thank you / kind regards

like image 632
user1759247 Avatar asked Mar 10 '26 23:03

user1759247


1 Answers

You can access the system property that contains the current working directory:

String currentDirectory = System.getProperty("user.dir");
like image 169
Simon Avatar answered Mar 13 '26 12:03

Simon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!