Here you can find the source of getFullPathOfClass(Class cls)
public static String getFullPathOfClass(Class cls)
//package com.java2s; /*//from www . ja v a2 s . c o m Copyright (c) 2013 eBay, Inc. This program is licensed under the terms of the eBay Common Development and Distribution License (CDDL) Version 1.0 (the "License") and any subsequent version thereof released by eBay. The then-current version of the License can be found at http://www.opensource.org/licenses/cddl1.php and in the eBaySDKLicense file that is under the eBay SDK ../docs directory. */ import java.net.URL; public class Main { public static String getFullPathOfClass(Class cls) { URL url = cls.getProtectionDomain().getCodeSource().getLocation(); String path = url.getPath(); String[] dirs = cls.getName().split("\\."); for (int i = 0; i < dirs.length - 1; i++) path += dirs[i] + "/"; return path; } }