I am creating an exe file using Launch4j plug-in in Gradle. My intention is to get the directory where I am while executing the exe file that is placed in another directory. For example, the exe file is placed in "C:\Utilities" and my current directory is "C:\temp". When I execute "C:\Utilities\my.exe", I would like to get "C:\temp" in my main method.
I tried this to send the result of %CD% as a system property -
createExe {
mainClassName = 'com.eldho.mp3tools.Mp3ToolsMain'
jvmOptions = ['-Dworking.dir="%CD%"']
}
But, it is turning up blank inside my method.
I also tried this inside the method -
Path currentRelativePath = Paths.get("");
String s = currentRelativePath.toAbsolutePath().toString();
logger.info("Current relative path is: " + s);
This gives the directory where the exe file is (C:\Utilities).
Any help is appreciated.