Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Library Jar Compatibility

 
Bimal Patel
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I compile a set of java class files with some library jar and while running it, I specify new library jar i.e. newer version of the library jar, will that affect? I think yes but not always. Comments?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classes in the new jar will be used at runtime, of course. Whether this will work or not depends on whether the public APIs of the classes have changed. As long as the new jar includes the classes your code uses, and those classes still have the methods you called, then things will link just fine. Now, if the behavior of those methods has changed, then you might still have some problems.
 
Bimal Patel
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response. I have the similer thoughts. What about the reverse case? I mean to say, compiled with the old lib jar and running with the new lib jar? I think same problem may occur in terms of if the behaviour of a method is changed. I don't know why but I feel that at both the times, one should always have the same versions of the lib jar.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bimal Patel:
I don't know why but I feel that at both the times, one should always have the same versions of the lib jar.


No, not really. If this was true, we wouldn't use jars at all -- you'd package everything into one indivisible blob to avoid this kind of problem. But being able to upgrade a libary without recompiling an application is a nice, useful, and valid thing to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic