[英]Generate jar from classes through java code - not commandline in eclipse
How can I convert the commandline: 如何转换命令行:
jar -cf myfile.jar *.class
to java code in Eclipse? Eclipse中的Java代码?
I hava all the classes pathes in the string. 我拥有字符串中的所有类路径。 I need to generate jar at runtime.
我需要在运行时生成jar。
First, you can create your command line and run it from java using either Runtime.getRuntime().exec(cmd)
or using ProcessBuilder
. 首先,您可以创建命令行并使用
Runtime.getRuntime().exec(cmd)
或使用ProcessBuilder
从Java运行它。
Second, jar is just a zip file. 其次,jar只是一个zip文件。 You can create it using either
ZipOutputStream
or JarOutputStream
您可以使用
ZipOutputStream
或JarOutputStream
创建它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.