

package scouter.toys.bytescope.util;


import scouter.toys.bytescope.AgentMain;

import java.io.File;

public class JarUtil {

	public static File getThisJarFile() {
		String path = "";
		ClassLoader cl = AgentMain.class.getClassLoader();
		if (cl == null) {
			path = ""
					+ ClassLoader.getSystemClassLoader().getResource(AgentMain.class.getName().replace('.', '/') + ".class");
		} else {
			path = "" + cl.getResource(AgentMain.class.getName().replace('.', '/') + ".class");
		}
		try {
			path = path.substring("jar:file:/".length(), path.indexOf("!"));
			if (path.indexOf(':') > 0)
				return new File(path);
			else
				return new File("/" + path);
		} catch (Throwable th) {
			return null;
		}
	}
}