java 什么是源 JAR?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30686312/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:29:57  来源:igfitidea点击:

What is a sources JAR?

java

提问by Nathan

I was recently trying to import a library to use for something I am working on.

我最近试图导入一个库来用于我正在做的事情。

https://sites.google.com/site/piotrwendykier/software/jtransforms

https://sites.google.com/site/piotrwendykier/software/jtransforms

I was having some difficulty because the JAR that I added to the build path was the "JTransforms-3.0-sources.jar" and not the "JTransforms-3.0.jar".

我遇到了一些困难,因为我添加到构建路径的 JAR 是“JTransforms-3.0-sources.jar”而不是“JTransforms-3.0.jar”。

Now I am sort of scratching my head and just wondering what that first sources.jar was if it didn't have any of the classes that I wanted to use in it.

现在我有点摸不着头脑,只是想知道第一个 source.jar 是什么,如果它没有我想在其中使用的任何类。

What is it and what is it for?

它是什么,它有什么用?

回答by jotadepicas

That sources jar is a jar that contains only the source code (the .java files) corresponding to the compiled artifact. It is useful to add it as a source attachment in your IDE, to publish the sources, etc.

该源 jar 是一个仅包含与编译工件对应的源代码(.java 文件)的 jar。将其添加为 IDE 中的源附件、发布源等很有用。

As it only contains sources, not compiled classes (.class files), it is of no use as a library dependency.

因为它只包含源代码,不包含编译的类(.class 文件),所以它不能用作库依赖项。

回答by hagrawal

What is it:Source JARs are the JAR file which contains only source code files i.e. .javafiles, and no compiled .classfiles. For example, you can download OpenJDK? Source files from http://download.java.net/openjdk/jdk8/

它是什么:源 JAR 是 JAR 文件,它只包含源代码文件,即.java文件,不包含编译.class文件。比如可以下载OpenJDK吗?源文件来自http://download.java.net/openjdk/jdk8/

What is it for:It is useful for other developers so that they can 'attach source' and debug into their project source code.

用途:它对其他开发人员很有用,以便他们可以“附加源代码”并调试到他们的项目源代码中。