Search code examples
javajar

What exactly does a jar file contain?


As an intern, I use company code in my projects and they usually send me a jar file to work with. I add it to the build path in Eclipse and usually all is fine and dandy.

However, I got curious to know, what each class contained and when I try to open one of the classes in the jar file, it tells me that I need a source file.

What does this mean? I come from a C/C++ background so is a jar similar to an already compiled .o file and all I can see is the .h stuff? Or is there actual code in the jar file that I'm using that's encrypted so I can't read it?


Solution

  • A JAR file is actually just a ZIP file. It can contain anything - usually it contains compiled Java code (*.class), but sometimes also Java sourcecode (*.java).

    However, Java can be decompiled - in case the developer obfuscated his code you won't get any useful class/function/variable names though.