I try to use JavaCompiler to compile source code.
class A{int i;};
class B extends A{i = 5;};
The problem is even if they are in the same folder, When compiling class B, JavaCompiler still can't find Class A.
So, I am wondering the problem is I didn't add the path of the folder to classPath.
I don't know how to do it in Java code, So didn't give it a shot.
You need to set the class path for the compile task.
Have a look at the answer over here: