测试编译class文件

master
Qin Dong Ming 2024-09-05 19:54:09 +08:00
parent b0530eec22
commit 04b478ca66
1 changed files with 1 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import javax.tools.ToolProvider;
public class JavaClass {
public static Result<Object> compile(String fileName) {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
String[] strings = {"-classpath", "/home/lib", "-verbose", "-d", "/home/lib", fileName+".java"};
String[] strings = {"-classpath", "/home", "-verbose", "-d", "/home", fileName+".java"};
int result = compiler.run(null, null, null, strings);
if (result == 0) {
System.out.println("编译成功,生成的.class文件位于源代码同目录");