使用Java程序编译Java文件 [英] Compile a Java file... with a Java program
问题描述
用Java编写的程序是否有可能使用JDK编译器编译文件(除了使用Java打开命令提示符并在其上抛出javac命令来编译文件)?
在Java 6及更高版本中,有一个API可以使用编译器。这可能就是你要找的。 p>
http://www.javabeat.net/2007/04/the-java-6-0-compiler-api/
http://docs.oracle.com/javase/6/docs/ api / javax / tools / JavaCompiler.html
请注意,您需要JDK来使编译器可用。 JRE是不够的。如果这是一个问题,请考虑在您的应用程序中嵌入Eclipse Java编译器。
Is it possible for a program written in Java to compile a file using the JDK compiler (aside from using Java to open command prompt and throw the "javac" command at it to compile the file)?
In Java 6 and onwards there is an API to use the compiler. This might be what you are 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 a JDK to have the compiler available. JRE will not be enough. If that is a problem consider embedding the Eclipse Java compiler in your application.
这篇关于使用Java程序编译Java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!