【问题标题】:Is there a possible way to copy a file to a jar file?有没有可能将文件复制到 jar 文件的方法?
【发布时间】:2014-07-26 10:49:55
【问题描述】:
我想问一个问题,是否有一种将文件(即图像)复制到 .jar 文件的方法,因为我想部署一个程序并且我创建了文件夹源代码(它们与源代码位于同一位置)和文件夹位于 jar 文件中(我使用 Netbeans 创建 jar 文件).....现在我想要的是我想将 JFileChooser 选择的文件复制到 jar 文件内的文件夹中????
任何想法都被欣然接受..!!!先谢谢了???
附:
我已经尝试在网上搜索答案,但他们只知道如何将 jar 文件中的文件复制到另一个目录......
【问题讨论】:
标签:
java
file
jar
directory
copy
【解决方案2】:
假设您要将文件 images/image1.gif 添加到 JAR 文件中。
jar uf <fileName>.jar images/image1.gif
要更改目录,请使用 -c
jar uf <fileName>.jar -C
在这个命令中
jar uf jar-file 输入文件
在这个命令中:
The u option indicates that you want to update an existing JAR file.
The f option indicates that the JAR file to update is specified on the command line.
jar-file is the existing JAR file that's to be updated.
input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.
Related Docs