Here you can find the source of getJarLocation()
public static String getJarLocation() throws URISyntaxException
//package com.java2s; //License from project: Open Source License import java.net.URISyntaxException; public class Main { /**/*from ww w .ja v a2s .c o m*/ * Gets the path of the running jar file */ public static String getJarLocation() throws URISyntaxException { String path = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); if (path.endsWith(".jar")) path = path.substring(0, path.lastIndexOf("/")); return path; } }