java - 有没有办法将文件复制到 jar 文件?

标签 java file jar directory copy

我想问一个问题,是否有将文件(即图像)复制到 .jar 文件的方法,因为我想部署一个程序并创建了文件夹源代码(它们与源代码位于同一位置)和文件夹在 jar 文件中(我使用 Netbeans 创建 jar 文件)......现在我想要的是我想将 JFileChooser 选择的文件复制到 jar 文件中的文件夹???? 任何想法都被衷心接受..!!!提前致谢????

附言: 我已经尝试在网上搜索答案,但他们只知道如何将 jar 文件中的文件复制到另一个目录......

最佳答案

假设您要将文件 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

关于java - 有没有办法将文件复制到 jar 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24060272/

相关文章:

file - 通过多次追加来检索写入文件的 gob

java - 如何从子模块构建目录添加 Artifact ?

java - 当项目是 .jar 或在 IDE 中时,如何动态访问 src/main/resources 中的文件

Java JDBC MySQL异常: “Operation not allowed after ResultSet closed”

java - 查找不相交的集合而不考虑字符串的大小写

php - 如何获取文件名?

java - 在空白处分割文本文件

java - 为什么我的返回值没有被正确识别?

java - 对象和引用计数 | java

JAR 文件中的 Java Applet