Get application directory
Trying to get application directory. I've tried a couple of different ways to get the applications directory.
This one returns the current directory so if I have a desktop shortcut to the jar file it returns curDir = path/to/desktop
When running this code from CMD it doesn't return anything.
String curDir = System.getProperty("user.dir");
Is there an easy way to get the applications directory?
URL mySource = Main.class.getProtectionDomain().getCodeSource().getLocation();
File sourceFile = new File(mySource.getPath());