简体   繁体   中英

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?

I hava all the classes pathes in the string. I need to generate jar at runtime.

First, you can create your command line and run it from java using either Runtime.getRuntime().exec(cmd) or using ProcessBuilder .

Second, jar is just a zip file. You can create it using either ZipOutputStream or JarOutputStream

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM