Compiling java files using Java programs

Is it possible for programs written in Java to compile files using the JDK compiler (in addition to using java to open a command prompt and throw a "javac" command on it to compile files)?

Solution

In Java 6 and later, there is an API that uses the compiler This may be what you're looking for

http://www.javabeat.net/2007/04/the-java-6-0-compiler-api/

http://docs.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html

Note that you need the JDK to make the compiler available JRE is not enough If this is a problem, consider embedding the eclipse java compiler in your application

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>