Here you can find the source of getClassAbsolutePath(Class> c)
public static String getClassAbsolutePath(Class<?> c)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLDecoder; public class Main { public static String getClassAbsolutePath(Class<?> c) { //ArrayUtil.class.getClass().getResource("/").getPath(); String filePath = c.getProtectionDomain().getCodeSource().getLocation().getFile(); try {/*from w w w . ja v a2 s.c om*/ return URLDecoder.decode(filePath, "UTF-8"); } catch (UnsupportedEncodingException e) { return null; } } }