Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a Java JAR file similar to an .Net Assembly?

I'm familiar with .Net and what assemblies are - but sadly my Java knowledge isn't as strong.

I know Java and .Net are different "worlds" (possibly like comparing apples with pears) but are JARs and .Net Assemblies roughly eqivalent concepts?

Edit: Update base on initial responses

The way I interpret this is that yes they have similarities:

  • Both can contain resources and metadata.

But there's some core differences:

  • a .Net assembly is compiled a JAR isn't.
  • JAR files aren't required to make a Java application; .Net assemblies are required for a .Net application.

[This isn't time for a religious war - I'd like to know if / how much of my understanding of .Net Assemblies I can apply to getting my head around Java (and maybe this will even help Java folks going the other way).]

like image 928
Adrian K Avatar asked Sep 15 '10 20:09

Adrian K


People also ask

Is assembly in C# same as package in Java?

No they are not same.

What is JAR equivalent in C#?

The jar equivalent in C# (basically in any . Net language) is dll (for class library) and exe (for executable one) or collectively assembly.

What is a .NET assembly file?

. NET defines a binary file format, assembly, that is used to fully describe and contain . NET programs. Assemblies are used for the programs themselves as well as any dependent libraries.

Is JAR and DLL same?

They play the same role, yes. . dll contains compiled IL code and . jar contains compiled .


2 Answers

There's a bunch of technical differences, but they are of little consequence most of the time, so basically, YES, they are the same concept.

like image 112
James Curran Avatar answered Sep 20 '22 19:09

James Curran


I would say no, they are not the same concept, noting that a JAR can be used like an assembly. If you really want to get your head around a JAR file, just think of it as a ZIP file. That's all it really is.

Most often, that archive contains compiled class files. And most often, those class files are arranged in a hierarchal fashion corresponding to the class's package.

But JAR files frequently contain other stuff, such as message bundles, images, and even the source files. I'd encourage you to crack one open with the unzip client of your choice and take a look inside.

The JAR format is however the most common way of packaging a distributable for a Java library or application so in that way they are very similar.

From a language standpoint, JAR files are in no way required to make a Java application or library, nor would I say they are intrinsic to Java, however both the standard library and the JDK has support for dealing with JAR files.

like image 33
Mark Peters Avatar answered Sep 18 '22 19:09

Mark Peters