• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why are JAR files created

 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi people,

i know how to create JAR files. But professionaly when are they created and for what purpose?
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a good question.

JAR - is an abbreviation of Java ARchive. Archive is a compressed version of many files, we can say in simple terms.

In order to have a related .class files into one archive file so that maintenance of those files into any application which is in need of it will be easy.

The purposes are
  • you can load any class from the JAR file
  • you can use it as a library reference to include the classes which are being imported into an application.



  • Does that help you?
     
    pras
    Ranch Hand
    Posts: 188
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks for the information


    one more doubt, suppose i have A.class,B.class and C.class in a single JAR file which has name XYZ.jar
    then how can i get only A.class file back


    one more doubt,
    can we get the java Source code back from a single .Class File?
     
    Rob Spoor
    Sheriff
    Pie
    Posts: 20512
    54
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by prasanna sheregar:
    one more doubt, suppose i have A.class,B.class and C.class in a single JAR file which has name XYZ.jar
    then how can i get only A.class file back

    JAR files are a special kind of ZIP files. Using a ZIP application, such as WinZip, TugZIP or Windows XP's built in unpacker, you can easily extract any file from a JAR file.

    one more doubt,
    can we get the java Source code back from a single .Class File?

    The original source? No. For instance, all comments will be removed, and sometimes the compiler optimizes code.

    Some decompilers do a good enough job though. I've used JADNT in the past with some good result. Still, it is never a replacement for having the original source.

    It is also possible to obfuscate compiled code. If this has occurred it is hard, if at all possible, to retrieve its source code.

    Final note: decompiling Java classes (or any program for that matter) can be illegal, depending on both the country and the origin of the compiled code.
    [ November 20, 2007: Message edited by: Rob Prime ]
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3381
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Simply speaking, its possible through 'Decompilation' through some tools like JAD.

    But you got a detailed explanation by Rob.
     
    Stan James
    (instanceof Sidekick)
    Ranch Hand
    Posts: 8791
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    A jar is often a "unit of deployment", a bundle of related code that should be released together. In a large system we might find different subsystems and frameworks divided into different jars. And in some environments it is important to be able to deploy one new jar without updating all the others.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic