java_home

MacOS/Java AppBundler error: NoSuchFileException: Info.plist

If you’re using the Oracle AppBundler to build a Mac/MacOS application bundle from a Java application and run into this error when running Ant:

NoSuchFileException: <directory path here> Info.plist

I have found that the problem is that I have not set and exported JAVA_HOME. To set and export JAVA_HOME on MacOS 10.12, I use this command in the shell script I use to build my Mac/Java app:

How to set the Java version on Mac OS X (macOS) systems alvin July 20, 2016 - 8:11pm

I don’t remember where I first found this line of code, but if you put it in your Mac OS X ~/.bash_profile file, it’s an easy way to set your Mac Java version:

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

I can confirm this works with the Bash shell on Mac OS X 10.10. When I run the java -version command after opening a new Mac Terminal window, the output is 1.8.0_25.

A slightly more difficult way to set your Mac Java version is to look under the /Library/Java/JavaVirtualMachines directory to see which versions are installed, and then manually set the version.

Mac OS X JAVA_HOME location (for Java JDK/SDK)

Java/Mac FAQ: Where is JAVA_HOME located on Mac OS X systems?

JDK location

This has changed over time, but if you're using Mac OS X 10.9 or newer, your JDK/SDK  JAVA_HOME location for Java 8 will be something like this:

/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

For Java 7 it was also in the same area:

/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/

Of course that will vary by the JDK version you have installed.

DOS batch files to compile and run a Java program (and create a jar file)

This isn't the most high-tech way to do things, but I thought I'd share these Windows (DOS) shell scripts that I'm currently using to compile a Java application, create a Jar file to distribute the application, and finally run the application. I ended up creating these scripts because of configuration problems on my Windows PC, but I thought they might be useful samples for others.