P@ Log

Patrick Chanezon about Platforms and Software Development

 

“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 java.io.FileOutputStream.(FileOutputStream.java:179)
at java.io.FileOutputStream.(FileOutputStream.java:131)
at sun.tools.jar.Main.extractFile(Main.java:711)
at sun.tools.jar.Main.extract(Main.java:677)
at sun.tools.jar.Main.run(Main.java :189)
at sun.tools.jar.Main.main(Main.java:903)

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.

1 response so far ↓

  • 1 Coach Thrasher // Oct 21, 2006 at 7:16 pm

    Fun with “Write Once, Run Anywhere”…

    Patrick Chanezon found some nice system-specific holes in Java’s “Write Once, Run Anywhere” mantra: different file systems behave differently WRT archiving files using the jar tool. What a pain.

    On windows the Jar tool doesn’t recognize dir…

Leave a Comment