“Write Once, Run Anywhere”: the devil is in the details
October 9th, 2006 · 1 Comment
Logging this weird platform specific inconsistency in java jar tool as an example of why the java mantra “Write Once, Run Anywhere” is difficult to achieve.
Recently I received a code drop from a third party, a java application that they developed on Linux. When I built it I received an IO Exception in jar. Tracing it I realized that the culprit was a jar xf command that failed to unjar one file, LICENSE.
Building assembly …
java.io.FileNotFoundException: LICENSE (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at sun.tools.jar.Main.run(Main.java :189)
Looking into it in more details, it was trying to jar xf a file called LICENSE in a directory where there was already a directory called license, small caps.
It seems that jar xf returns without errors on linux, and with an error on Mac OS X. I guess it must be the behavior of the underlying file system.