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:
Three assumptions in this process are:
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
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.
Include the JUnit library in your project, and use it in the same way you’ve used it in Java projects, with a few minor changes.
Assuming you’re using SBT on your project, include JUnit into the project by adding this dependency line to your build.sbt file:
If you don't do anything to your Java application on a Mac OS X system, your Java class name will appear in the Mac menubar. Of course, this isn't a good thing. There are a couple of things you can do to get the name of your Java application on the Mac menu bar, and I'll share all of the ways I know how to do this. I've listed these techniques in order here from "easiest" to "best".
Java obfuscator/obfuscation FAQ: How can I obfuscate my Java class files so they can't easily be decompiled? (Or, how do I use ProGuard to obfuscate my Java class files?)
Java Mac application FAQ: Can you share a Java/Mac Ant build script that uses the Jarbundler task to make my Java application look like a native Mac OS X application?
NOTE: This solution is for Mac OS X systems running versions of Java prior to Java 7. If I remember right, it only works on those systems, and therefore only on Mac OS X systems 10.6 and earlier. I'm working on new tutorials for Java 7 and Mac OS X 10.7, 10.8, 10.9, and newer.
Lately I've been doing a lot of Java programming on Apple's Mac OS X platform, and my most recent effort has been to handle drag and drop events in my Java Swing application. Not satisfied to handle "simple" drag and drop events, I decided I wanted to take my application even farther, and let users drag files and images to my Java application icon in the Mac Dock.
Over the last three days I've created a new Java Swing application for the Mac OS X platform, and today I'm giving away all the source code for this project (free of charge). The complete project includes both (a) all the Java source code and (b) all of the Ant build script code needed to build this application. The end result of the build is what appears to the end user to be a native Mac OS X application.