ho fatto banalmente così:
non so se sia la migliore soluzione, ma è l'unica cosa veloce che mi è venuta in mente.codice:public String jarPath() throws UnsupportedEncodingException { String pathJar = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) { pathJar = pathJar.replaceAll("/", "\\\\"); } int p = pathJar.lastIndexOf(":"); int s = pathJar.lastIndexOf(File.separator); String path = pathJar.substring(p + 1, s + 1); return path; }

Rispondi quotando