The Mac/Java/Ant AppBundler error, java.nio.file.NoSuchFileException: Info.plist

As I learned recently, the Mac/Java AppBundler tool is a little out of date these days, but you can still use it with Java 8 and MacOS 10.12 to build Mac/Java applications. One problem you can run into is getting this ugly Info.plist error:

java.nio.file.NoSuchFileException: /Users/al/Example/Info.plist
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:526)
    at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)
    at java.nio.file.Files.copy(Files.java:1274)
    at com.oracle.appbundler.AppBundlerTask.copy(AppBundlerTask.java:566)
    at com.oracle.appbundler.AppBundlerTask.copyRuntime(AppBundlerTask.java:357)
    at com.oracle.appbundler.AppBundlerTask.execute(AppBundlerTask.java:290)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)

That Ant error message goes on for a long time, but that gives you the general idea of the error. It complains that you don’t have an Info.plist file, but that’s not the problem at all. As it turns out, the problem happens when your JAVA_HOME variable is not set and exported.

To avoid this error — and fix the problem — just make sure JAVA_HOME is set properly. On my MacOS 10.12 system that uses Java 8, I set it in a shell script I use to call Ant like this:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Magically, as soon as I set and export JAVA_HOME like that, the Info.plist error goes away.