如何将java类添加到jar文件中的文件夹 [英] how to add a java class to a folder within a jar file
问题描述
在Windows命令提示符下使用jar,如何将foo.class添加到foo.jar中的文件夹classes?
using jar on the windows command prompt, how can I add foo.class to a folder "classes" in foo.jar?
我可以将文件添加到jar使用
I can add the file to the jar using
jar uvf foo.jar foo.class
jar uvf foo.jar foo.class
但是这不会把类放在jar中的classes文件夹中。
but that doesn't put the class in the "classes" folder in the jar.
我知道我可以使用winzip来解压缩jar,添加文件,然后再将其压缩,但这很慢,希望不必要。
I know I can use winzip to unzip the jar, add the file, and zip it up again, but that's slow and hopefully unnecessary.
推荐答案
将 foo.class
放入 classes
目录,然后运行
jar uvf foo.jar classes/foo.class
(我刚试过它以确保它有效。可能一种方式这样做而不创建类
目录,但我认为这是最简单的解决方案。)
(I've just tried it to make sure it works. There may a way of doing it without creating the classes
directory, but I think this is the simplest solution.)
这篇关于如何将java类添加到jar文件中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!