Linux 使用 jar 命令将 war 解压到一个目录。这可能吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4266880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
unpack war to a directory using jar command.is that possible?
提问by black sensei
I've search online a way to unpack a war file from a location to a different one, and so far nothing satisfactory. i use this command
我在网上搜索了一种将战争文件从一个位置解压缩到另一个位置的方法,但到目前为止没有任何令人满意的方法。我用这个命令
jar -xvf mysite.war -C /usr/local/tomcat/webapps/mysite/
it's not working.this :
它不起作用。这个:
jar -xvf mysite.war /usr/local/tomcat/webapps/mysite/
is not throwing any error but still not working any idea?
没有抛出任何错误但仍然没有任何想法?
回答by darioo
A warfile is a zipped archive. Perhaps using unzipwill work.
一个war文件是压缩文档。也许使用unzip会奏效。
回答by rhellem
Found the blog post at mkyong.com
As stated there: "...jar does doesn't has option to extract files to another folder directly..."So what you need to do is change to the directory you want to extract to, and then refer the jar-file from there
正如那里所述:“...jar 没有直接将文件解压缩到另一个文件夹的选项...”所以你需要做的是更改到要解压缩到的目录,然后引用 jar 文件从那里
mkdir newdir
cd newdir
jar -xvf /workspace/test/classes/test.jar
This will do the trick for you on Windows as well, since unzip is not available there by default.
这也可以在 Windows 上为您解决问题,因为默认情况下解压缩在那里不可用。

