The jar file metadata could have been a boon to better module management of Java application
All Java programmers have run into, one time or another, the problem where a specific class is not behaving like it is supposed to. After banging your head on the monitor countless times, you suddenly realize that the wrong version of the class file has been loaded, and you start to track down which jar file has been loaded from which class path.
That should be easy to fix. You swap out the wrong version, and swap in your right version, and re-start your application. Then suddenly, other parts of the application are having problems too. That’s right, your module needs a specific version of a jar package, another module needs another version of the same jar package. The annoying part is just that both versions are not really compatible.
Welcome to the jar files hell!
That’s right, one really annoying part of Java programming is the management issue of the jar files. Deployment and distribution are also messy. I suddenly have an urge to vent about it when a co-worker bumps into this issue again.
This is exactly the same problem as the DLL hell in Windows programming, which we all love to hate.
However, Java had a chance to avoid the issue, but it totally missed it. The jar file specification has defined a great deal of metadata, including version information, class path information, etc, and a very thorough extension mechanism which could have been used to extend the functionality. This could have been used as a framework for managing jar file dependency chains, and the class loader should be smart to figure out which version of the same jar file to load. How the Java kernel is going to manage multiple versions of the same Java class is matter for another discussion.
Alas, the jar file specification had failed to carve itself a place in the annals of computing.
Java 7 promises a new modular platform by splitting the monolithic JDK into manageable modules, with a well-defined framework for declaring dependencies. Let’s just hope that this heroic efforts will bear fruit. I’ll look further into the new platform in a future post.