0

I need some help with using the following code to modify and existing jar file:

    String command = "cmd /c jar uf " + dirToModify + " " + Main.getMain().outputLocate.getSelectedFile();
    try {
        Runtime.getRuntime().exec(command);
    } catch (IOException e) {
        e.printStackTrace();
    }

    dirToModify = "C:\\Users\\Me\\Desktop\\myfile.jar"
    Main.getMain().outputLocate.getSelectedFile() = "C:\\Users\\Me\\Desktop\\myfolder"

Basically I want to add the files/folders from myfolder to myfile.jar but with the above code it will add a shortcut to my C: drive not the files from myfolder.

Also I did look at other posts but none help me with this problem.

Any help with this would be greatly appreciated.

4

1 回答 1

0

我建议,首先检查一次添加一个文件是否正在使用此代码。这将清楚问题是否在“文件夹添加”或“文件添加”中。如果文件添加不起作用,则您的基本 jar 更新逻辑已损坏。因此,您可以要求解决该问题。如果文件添加有效,请尝试递归添加目标文件夹中的所有文件。

于 2013-10-26T09:25:19.453 回答