有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

带有文本文件和文件夹的Java bundle Jar

这里有个小问题。我有一个项目,可以读取多个文本文件并在文件夹之间移动文件。有没有办法将这些文件与jar捆绑在一起?因为我必须将jar包装在一个可执行文件中

谢谢


共 (1) 个答案

  1. # 1 楼答案

    你可以用罐子包装任何东西。jar基本上只是一个zip文件。从Oracle Documentation

    The basic format of the command for creating a JAR file is:

    jar cf jar-file input-file(s)

    The options and arguments used in this command are:

    The c option indicates that you want to create a JAR file.

    The f option indicates that you want the output to go to a file rather than to stdout.

    jar-file is the name that you want the resulting JAR file to have. You can use any filename for a JAR file. By convention, JAR filenames are given a .jar extension, though this is not required.

    The input-file(s) argument is a space-separated list of one or more files that you want to include in your JAR file. The input-file(s) argument can contain the wildcard * symbol. If any of the "input-files" are directories, the contents of those directories are added to the JAR archive recursively.