Reputation: 228
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.
Upvotes: 1
Views: 3414
Reputation: 660
another point of view would be to generate directly the bytecode using one of the famous tools for such task like ASM, JavaAssist, SERP or any other one..... It could be a very good way to avoid : - path problems - to have a finer control on the process (if you have javac errors you will be obliged to parse the stream to raise thme into your application) - improve the whole process performance
But it adds some complexity... Like often it's a trade off
Upvotes: 1
Reputation: 3671
extend the classpath to the current directoy.
You can do that via the -classpath option or the CLASSPATH variable.
-claspath=.
or
CLASSPATH=.
Upvotes: 0
Reputation: 421280
You need to set the class path for the compile task.
Have a look at the answer over here:
Upvotes: 4