• Post Reply Bookmark Topic Watch Topic
  • New Topic

I'm using Java but I'm still an idiot - Jar question  RSS feed

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, what is it really inside a jar file? If packages are stored inside a jar file, how do you use it on another application especially if the other app has the same package name as that of the jar file???
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open one and see

You can put whatever you like in a jar file, but one normally contains:
  • A bunch of class files
  • A Manifest file
  • and possibly some properties files


  • If packages are stored inside a jar file, how do you use it on another application

    By including the jar in the classpath.


    if the other app has the same package name as that of the jar file

    If the same classes exist in more than one jar in an application's classpath usually its whatever class the class loader finds first that "wins". One gets loaded, the other ignored.
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!