java Java中jar文件和库的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14264337/
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
Difference between a jar file and a library in Java
提问by Deepak Singhal
NetBeans
allows the programmer to add a library
and a jar
file.
NetBeans
允许程序员添加一个library
和一个jar
文件。
What is the difference between a jar file and a library? Is library similar to GAC assembly
as in Windows
.
jar 文件和库有什么区别?是库类似于GAC assembly
作为Windows
。
There are similar questions, but they are way too specific and I was not able to understand the difference.
有类似的问题,但它们太具体了,我无法理解其中的区别。
回答by Deepak Singhal
to put things very simple : library is a collection of jars
把事情说得很简单:图书馆是罐子的集合
You could like create a global library java-ee which contains all Java EE related jar files. Then you could use this global library in your different projects. It will be simpler to manage them; and adding in new projects.
您可能喜欢创建一个全局库 java-ee,其中包含所有与 Java EE 相关的 jar 文件。然后你可以在你的不同项目中使用这个全局库。管理它们会更简单;并添加新项目。
回答by Paul Sanwald
A JAR serves the same function an an Assembly in the C#/.net world. It's a collection of java classes, a manifest, and optionally other resources, such as properties files.
JAR 提供与 C#/.net 世界中的程序集相同的功能。它是 Java 类、清单和可选的其他资源(例如属性文件)的集合。
A library is a more abstract concept, in java, a library is usually packaged as a JAR (Java ARchive), or a collection of JARs.
库是一个比较抽象的概念,在java中,库通常被打包成一个JAR(Java ARchive),或者JAR的集合。
回答by John Ballard
A jar file is zip archive containing among other files, the java class files. A Netbeans library contains resources required by the project, including jar files.
jar 文件是 zip 存档,其中包含 Java 类文件等其他文件。Netbeans 库包含项目所需的资源,包括 jar 文件。
回答by John Ballard
回答by Joseph Farrugia
If well understood: A library is simply a folder that groups classes. For example in JDK, a library present there is a group of classes stored together.
如果很好理解:库只是一个对类进行分组的文件夹。例如在 JDK 中,一个库存在一组存储在一起的类。
If not mistaken a .jar file is a group of compiled classes in .class format and was created by Java creators so a program will be OS independent; which means within a JVM you will run your app in .jar format on a Linux, Windows, etc without re-coding tour app for various OSs.
如果没记错的话,.jar 文件是一组 .class 格式的编译类,由 Java 创建者创建,因此程序将独立于操作系统;这意味着在 JVM 中,您将在 Linux、Windows 等系统上以 .jar 格式运行您的应用程序,而无需为各种操作系统重新编码 Tour 应用程序。