diff --git a/src/main/java/bytecode/ClassCodeGen.java b/src/main/java/bytecode/ClassCodeGen.java index a59a632..77316a6 100644 --- a/src/main/java/bytecode/ClassCodeGen.java +++ b/src/main/java/bytecode/ClassCodeGen.java @@ -4,6 +4,7 @@ import ast.ClassNode; import ast.FieldNode; import ast.MemberNode; import ast.MethodNode; +import java.io.File; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; @@ -34,8 +35,13 @@ public class ClassCodeGen { } private void printIntoClassFile(byte[] byteCode, String name) { - String filePath = "./classFileOutput/" + name + ".class"; + String directoryPath = "src/main/java/classFileOutput"; + File directory = new File(directoryPath); + if (!directory.exists()) { + directory.mkdirs(); + } + String filePath = directoryPath + "/" + name + ".class"; try { FileOutputStream fileOutputStream = new FileOutputStream(filePath); fileOutputStream.write(byteCode);