通过Eclipse创建的可运行JAR文件是否包含跟踪信息?

10

假设我在Eclipse中编写Java代码,然后将其保存为可运行的.jar文件。这段代码是100%自己编写的,没有从其他来源导入。

在.jar文件中是否有任何私人数据(文件头等)与我的PC或我的Eclipse版本有关?


1
为什么不打开它看看呢?你不需要担心.class文件。除非你在Class-Path中硬编织绝对路径,否则答案是“否”。 - duffymo
请检查您的jar文件中的清单。如果有的话,这是唯一可能包含此类信息的地方。 - G-Man
3个回答

13

是的,可能存在自动生成清单文件 (jar:META-INF/MANIFEST.MF)

这是插件的默认输出

Manifest-Version: 1.0
Built-By: borisov andrey
Build-Jdk: 1.7.0_05
Created-By: Apache Maven
Archiver-Version: Plexus Archiver

正如您所看到的,至少将用户名添加到清单文件中

更新:如果您使用Maven,则可能希望配置Maven Jar插件

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>${maven-jar-plugin-version}</version>
      <inherited>true</inherited>
      <executions>
        <execution>
          <goals>
            <goal>test-jar</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <archive>
          <manifestEntries>
            <Created-By>${java.version} (${java.vendor})</Created-By>
            <Built-By>ME</Built-By>
            <Implementation-Title>${project.name}</Implementation-Title>
            <Implementation-URL>SOME URL if you want</Implementation-URL>
            <Implementation-Version>${project.version}</Implementation-Version>
            <Implementation-Vendor>your company</Implementation-Vendor>
            <Implementation-Vendor-Id>your vendore id</Implementation-Vendor-Id>
          </manifestEntries>
        </archive>
      </configuration>
    </plugin>

4
built-by 这个东西是 Maven 添加的,它不是 Java 本身的“标准”或必需品。 - A.H.
好的,顺便说一句,谢谢。但是还是值得检查 META-INF/MANIFEST.MF。 - Andrey Borisov
非常感谢,如果只有默认添加用户名,那么Java编程就像应该具有的隐私安全一样。 - Tom

0

如果在创建可运行的JAR文件时将这些内容设置为元数据,我会感到惊讶。


0

你的可运行jar文件中只会包含资源依赖库manifest.xml文件。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接