Solution to what I need:
The only Solution that Works for me on Linux, Mac and Windows:
public static String getJarContainingFolder(Class aclass) throws Exception {
CodeSource codeSource = aclass.getProtectionDomain().getCodeSource();
File jarFile;
if (codeSource.getLocation() != null) {
jarFile = new File(codeSource.getLocation().toURI());
}
else {
String path = aclass.getResource(aclass.getSimpleName() + ".class").getPath();
String jarFilePath = path.substring(path.indexOf(":") + 1, path.indexOf("!"));
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8");
jarFile = new File(jarFilePath);
}
return jarFile.getParentFile().getAbsolutePath();
}
found in the post: https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file
Try one of these: http://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file
– user28595
Thank you for the indication. I found the reply there.
– Jeremias Santos