Sunday, November 23, 2014

What is the Order of Precedence, if `a.jar` as well as `a.class` both are available in the same folder?

Assume `a.class` is packed into `a.jar`

If both are available in the same folder, then the below command searches for the class in the jar than current folder.

$ java a

search for `a.class` in `a.jar`.

If not found then takes the `a.class` in the current folder.

JAR file got higher precedence. So careful with your updates or modifications to the class.

If you didn't jar it again then `java` uses the old jar only even though the new class file is existing in the current folder. And you end up in wondering about the unaffected changes.