首页 \ 问答 \ apache tomcat7 配置问题

apache tomcat7 配置问题

apache tomcat7 没有配置环境变量,但是在dos里面运行startup.bat 显示也很正常,就是在bin下面点击startup.bat却一闪而过  怎么回事
更新时间:2022-08-22 21:08

最满意答案

一个jar文件是围绕ZIP文件格式构建的,通常包含一个清单文件 ,该清单文件是包含在jar文件中的所有文件的列表。 这个清单(如果存在的话)将具有名称META-INF/MANIFEST.MF ,它将是一个文本文件。

因此,通过从每个要比较的jar对中提取清单,然后查找差异,可以实现您想要的结果。

如果您有可用的jar命令,则可以使用以下命令提取jar文件的清单:

jar xf jar1.jar META-INF/MANIFEST.MF

如果你有可用的话,你也可以使用unzip做到这一点。

一个简单的脚本将从两个jar文件中提取清单并使用diff比较它们,如下所示:

#!/usr/bin/env bash

jar xf "$1" META-INF/MANIFEST.MF
mv META-INF/MANIFEST.MF m1.txt
jar xf "$2" META-INF/MANIFEST.MF
mv META-INF/MANIFEST.MF m2.txt

diff m1.txt m2.txt

该脚本需要两个参数,jar文件。 如果您希望清单中的文件是相同的,但顺序不同,您可以尝试按排序先sort 。 这只是一个脚本的骨架。 您可能想要添加文件清理,错误检查等等。

如果你只关心jar文件中的文件,你可能会得到它们的列表:

jar tf jar1.jar

您也可以使用unzipunzipunzip -l jar1.jar如评论所示。

然后你可以用类似的方式diff文件列表,也许可以先排序排序它们。

还有一个相关的问题: 如何使用Bash从JAR读取MANIFEST.MF文件


A jar file is built around the ZIP file format and usually contains a manifest file which is a list of all the files that are included in the jar file. This manifest, if it exists, will have the name META-INF/MANIFEST.MF and it will be a text file.

So what you want may be achieved by extracting the manifest from each jar pair you want to compare and then looking for differences.

If you have the jar command available, you may extract the manifest of a jar file with:

jar xf jar1.jar META-INF/MANIFEST.MF

You may also do this with unzip if you have it available.

A simple script that would extract the manifests from two jar files and compare them using diff would look like:

#!/usr/bin/env bash

jar xf "$1" META-INF/MANIFEST.MF
mv META-INF/MANIFEST.MF m1.txt
jar xf "$2" META-INF/MANIFEST.MF
mv META-INF/MANIFEST.MF m2.txt

diff m1.txt m2.txt

The script takes two parameters, the jar files. If you expect the files in the manifests to be the same but in different order, you may try sorting them first with sort. This is only the skeleton of a script. You may want to add things like file cleanup, error checking and so on.

If you only care about the files inside the jar files, you may get a list of them with:

jar tf jar1.jar

You may also use unzip for this: unzip -l jar1.jar as suggested in a comment.

Then you may compare the list of files with diff in a similar fashion, maybe sorting them with sort first.

There is also a related question: How to read MANIFEST.MF file from JAR using Bash.

相关问答

更多
  • 一个jar文件是围绕ZIP文件格式构建的,通常包含一个清单文件 ,该清单文件是包含在jar文件中的所有文件的列表。 这个清单(如果存在的话)将具有名称META-INF/MANIFEST.MF ,它将是一个文本文件。 因此,通过从每个要比较的jar对中提取清单,然后查找差异,可以实现您想要的结果。 如果您有可用的jar命令,则可以使用以下命令提取jar文件的清单: jar xf jar1.jar META-INF/MANIFEST.MF 如果你有可用的话,你也可以使用unzip做到这一点。 一个简单的脚本将 ...
  • 你看过这个工具OneJar吗? 这也是阅读OneJar的好文章。 如果您决定不使用外部工具,那么您可以选择将库/助手罐放入清单中的classpath中,然后将罐子本身复制到相对于主jar的目录路径中。 编辑:OP问一个例子MANIFEST.MF。 我从示例One-Jar示例 jar文件处理了这个问题。 Manifest-Version: 1.0 Main-Class: com.simontuffs.onejar.Boot One-Jar-Expand: expand,doc Have you looked ...
  • 不是每个jar文件都是可执行的。 现在,您需要在java文件中导入jar下的类。 例如, import org.xml.sax.SAXException; 如果您正在使用IDE,那么您应该参考其文档。 或者至少在这个线程中指定你在这里使用哪一个。 这肯定会使我们能够进一步帮助你。 如果您没有使用任何IDE,那么请查看javac -cp选项。 但是,将程序打包到一个jar文件中,并且包括所有必需的jar在这里是更好的主意。 那么,为了执行你的jar ,就像, java -jar my_program.jar ...
  • 将其保存为findclass.sh(或任何),将其放在您的路径上并使其可执行: #!/bin/sh find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \; 第一个参数是递归搜索的目录,第二个参数是要搜索的正则表达式(通常只是一个简单的类名称)。 $ findclass.sh . WSSubject 该脚本依赖于jar命令的-t选项(其中列出了内容),并且对每个目录进行了grep,并将其与找到的JAR文件的路径 ...
  • 最后,我找到了解决方案: final String path = "sample/folder"; final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()); if(jarFile.isFile()) { // Run with JAR file final JarFile jar = new JarFile(jarFile); final ...
  • 版本化的jar文件总是一个好主意 该版本立即可见,您可以轻松找出冲突。 我看不到任何实质性的* con。 不,只有在两个或多个jar文件**中存在冲突的类文件时,jar文件的名称才有意义。 *:例如,不重要的缺点,例如可执行文件夹可能更容易输入,而无需版本编号 **:例如,如果您在两个jar文件中拥有com.foo.Bar类,那么类加载器将加载任意一个,通常取决于首先找到哪个类。 如果您有两个版本的相同jar文件,则同样适用 - 您通常不知道将使用哪个版本。 Versioned jar-files are ...
  • 很抱歉告诉你,但除非你实现自己的自定义类加载器,否则你不能在Java中嵌套这样的jar文件。 例如,参见这个讨论 。 但是,您可以使用One-Jar等工具合并 jar文件。 相关答案 。 ( woho,这是我的第1000个答案 :) I'm sorry to tell you, but unless you implement your own custom class loader, you can not nest jar-files like that in Java. See for instanc ...
  • 将依赖jar类文件复制到项目jar文件中: 使用Maven插件maven-shade-plugin命令: mvn package 下的所有类文件都将包含在项目jar文件中。 com.googlecode.json-simple json-simple 1.1.1
  • 此页面列出了文件系统的常见限制: http : //en.wikipedia.org/wiki/Comparison_of_file_systems 正如您在“限制”部分中所看到的,几乎没有文件系统允许超过255个字符。 您唯一的机会是编写一个程序来提取文件并缩短文件名太长。 Java至少应该能够打开存档(尝试jar -tvf列出内容;如果可行,截断也应该有效)。 java.util.jar can handle it: try { JarFile jarFile = new JarFile("/p ...
  • 我设法用ant-contrib实现了这一点(感谢Chad Nouis提供的属性中的CDATA提示):