I safely assume that every one working on Java/J2EE platform must have come across class loading issues. Some (like Hrish) have the knack to crack them very efficiently. Some, like me, grope when trying to figure out the problem. Java says the first class it encounters in the classpath is picked up and the other versions of the same class later in the classpath are ignored. That sounds pretty simple. However, in some cases, jars contain manifest files pointing to various other jar files/locations. In such cases, it becomes very difficult to check where the class is being loaded from, unless you have good amount of patience to perform a search in TextPad and go through all the results for possible class loading issues. There have been few annoying situations because of the wrong class files picked up from the class path.
Here is the best way I use to figure out from which jar the class is being picked up. Start the java program with -verbose switch and it will print out the class being loaded and the jar/location from where it is being picked up. Sounds simple right? Yeah, but one caveat is, this would work only with Tiger(JDK5) version onwards. Good luck in your classloading issues, if any.
PS: Want to know the fancy names for various Java versions? Click here
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment