我有一个jar文件和一个类文件。我想从两者创建一个JAR文件。可能吗?请帮我一下。 我试过了 Jar -cf new.jar sample1.class sample2.jar
它没有帮助
答案 0 :(得分:1)
将所有课程转移到一个文件夹中,比如它在C:\Folder\Project\
从命令提示符转到同一文件夹。并执行以下代码:
jar cfv Project.jar *
在上面的命令中,c will create jar
,f will transfer the content into the file i.e Project.jar
和v will print the process done into the console
。
* (WildCard)
将获取文件夹中的所有文件,相应的jar将在同一文件夹中创建。
您可以在DOCS中找到更多信息。 http://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html
与此同时,我建议您浏览以下链接,您可以使用Ant or Maven.
答案 1 :(得分:1)
不确定您要做什么,但从技术上讲,您可以使用:
cp sample2.jar new.jar
jar uvf new.jar sample1.class
当然,如果你已经在sample2.jar中有类sample1.class,它将被sample1.class覆盖(“u”== update)