[英]jar file with source code only
Suggest I have a HelloWorld.jar file, this file contains only HelloWorld.java , which is the source code of the application. 建议我有一个HelloWorld.jar文件,这个文件只包含HelloWorld.java,它是应用程序的源代码。
Will it be possible to run this jar file and execute the application, even though I don't have HelloWorld.class? 是否可以运行此jar文件并执行应用程序,即使我没有HelloWorld.class?
Directly? 直? No.
java
accepts only classfiles. 不,
java
只接受classfiles。 To use source it must be compiled with javac
. 要使用源代码,必须使用
javac
进行编译。 Nothing keeps you or a utility from compiling the source files to class files and using those , however. 但是,没有什么能阻止您或实用程序将源文件编译为类文件并使用它们 。
Yes, it can be done: See the javax.tools api . 是的,可以这样做: 参见javax.tools api 。 It is not easy, but it can be done....
这不容易,但可以做到....
You will likely be better off with a script that unjars the file, compiles it, and runs it. 使用解压缩文件,编译并运行文件的脚本可能会更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.