如何将java类添加到jar文件中的文件夹 [英] how to add a java class to a folder within a jar file

查看:1443
本文介绍了如何将java类添加到jar文件中的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆