Suggest I have a HelloWorld.jar file, this file contains only HelloWorld.java , which is the source code of the application.
Will it be possible to run this jar file and execute the application, even though I don't have HelloWorld.class?
Directly? No. java
accepts only classfiles. To use source it must be compiled with 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 . 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.