Reputation: 235
Is it possible to dynamically compile an external .java file using the Java compiler that eclipse uses rather than JDK?
What I want my code to do is:
I know how to do steps 1 and 3 but is step 2 possible just using Eclipse or are there better ways to accomplish what I want?
Upvotes: 0
Views: 115
Reputation: 235
I ended up using Eclipse's batchCompiler found in org.eclipse.jdt.core.compiler.batch.BatchCompiler: https://help.eclipse.org/2019-03/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_batch_compiler.htm
Upvotes: 0
Reputation: 34137
Yes, you can use the Java compiler for that. You do not need to compile the .java
file, just parse it to get an abstract syntax tree (AST) containing the information:
Upvotes: 1