user1825817
user1825817

Reputation:

Difference between a jar file and a library in Java

NetBeans allows the programmer to add a library and a jar file.

What is the difference between a jar file and a library? Is library similar to GAC assembly as in Windows.

There are similar questions, but they are way too specific and I was not able to understand the difference.

Upvotes: 19

Views: 18701

Answers (5)

Deepak Singhal
Deepak Singhal

Reputation: 10866

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.

Upvotes: 21

user1825817
user1825817

Reputation:

This article explains it all..

It states

Java's libraries are commonly known as class libraries. However, Java refers to class libraries as packages.

Upvotes: 1

Paul Sanwald
Paul Sanwald

Reputation: 11329

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.

A library is a more abstract concept, in java, a library is usually packaged as a JAR (Java ARchive), or a collection of JARs.

Upvotes: 5

Joseph Farrugia
Joseph Farrugia

Reputation: 327

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.

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.

Upvotes: 1

John Ballard
John Ballard

Reputation: 11

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.

Upvotes: 1

Related Questions