我试图从 .jar 中提取一个 .class 文件,它可以工作,但后来我改变了一些东西,现在我得到了这个错误:
java.lang.ClassFormatError: Invalid constant pool index 63
这是我的代码:
String path = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getFile()).getAbsolutePath();
if (path.endsWith("."))
path = path.substring(0, path.length() - 1);
String decodedPath = URLDecoder.decode(path, "UTF-8");
File file = new File(decodedPath + (decodedPath.endsWith("\\") ? "Classfile.class" : "\\Classfile.class"));
InputStreamReader read = new InputStreamReader(FileSync.class.getResourceAsStream("/Classfile.class"));
FileWriter write = new FileWriter(file);
int c;
while ((i = read.read()) > -1) {
write.write(i);
}
write.flush();
read.close();
write.close();
ProcessBuilder builder = new ProcessBuilder(System.getProperty("java.home") + "\\bin\\java.exe", "Classfile", decodedPath + (decodedPath.endsWith("\\") ? "Program.jar" : "\\Program.jar"));
builder.directory(file.getParentFile());
Process process = builder.start();
任何人都可以帮忙吗?