// 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.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class ClassnameFinder {
    private static byte[] load(String fnm) throws IOException {
        File f = new File(fnm);
        byte[] b = new byte[(int)f.length()]; 
        InputStream is = new FileInputStream(f);
        is.read(b);
        is.close();
        return b;
    }
    public static String getClassname(String fnm) throws IOException, ClassNotFoundException {
        ClassnameFinderHelper help = new ClassnameFinderHelper();
        return help.getClassname(load(fnm));
    }
    public static void main(String[] args) throws Exception {
        System.out.println(getClassname("C:\\X.class"));
    }
}

class ClassnameFinderHelper extends ClassLoader {
    public String getClassname(byte[] bc) {
        return defineClass(null, bc, 0, bc.length).getName();
    }
}
