// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.*;
import java.io.*;

public class GetPath {
    private static String getPath() {
        String cn = GetPath.class.getName();
        StringTokenizer st = new StringTokenizer(cn,".");
        StringBuffer sb = new StringBuffer("");
        boolean first = true;
        while(st.hasMoreTokens()) {
            if(first) {
                first = false;
            } else {
                sb.append("/");
            }
            sb.append(st.nextToken());
        }
        sb.append(".class");
        String path = GetPath.class.getClassLoader().getSystemResource(sb.toString()).getPath();
        int ix = path.indexOf("!");
        if(ix >= 0) {
            path = path.substring(0, ix);
            int ix2 = path.lastIndexOf("/");
            return path.substring(6, ix2 + 1);
        } else {
            int ix2 = path.lastIndexOf("/");
            return path.substring(1, ix2 + 1);
        }
    }
    public static void main(String[] args) {
      System.out.println(getPath());
    }
}
