Startseite bisherige Projekte Tools/Snippets Bücherempfehlungen Publikationen Impressum Datenschutzerklärung

Find JAR PositionFebruary 2015

Find position of the JAR file containing the current classes.

/**
 * @return the jar file that contains MyClass as File.
 */
private static File getCurrentJarFile() throws Exception{
    String path =MyClass .class.getProtectionDomain().getCodeSource().getLocation().getPath();
    String decodedPath = URLDecoder.decode(path, "UTF-8");
    return new File(decodedPath).getAbsoluteFile();
}
Impressum - Datenschutzerklärung