This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
Work Hard, Expect The Worst...<br /> <br />Bimal R. Patel<br />(SCJP 1.2, SCWCD 1.4)
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.
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.
author and iconoclast
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.