How to create a runnable jar file from source code programmatically?
问题 I need to create runnable .jar file programmatically from a string. My decision is to create a .class file from string and add it to the .jar using JarOutputStream. What API must I use to create the .class file? Are there any other solutions to create a .jar from the source code? 回答1: In order to do that, you can use the Java Compiler API. There is this excellent tutorial that can walk you through. 回答2: To compile code, you need a compiler. You can either use the Sun Oracle compiler or the