main()
method from the command line but the wider audience expects a double-clickable icon that looks and acts like every other native application. In this article, we travel from one end of the spectrum to the other to broaden your potential user base..app
. Even on a Windows machine you should be able to modify your build script to package up a Mac-specific version of your application.JavaSoundDemo
directory you will find the source files inside of the src
subdirectory, a jar file, audio files, and html files that we will not use.src
directory generates fifty class files. You can then run the sample application from the command line like this.java JavaSound
JavaSoundDemo.jar
is executable. Because Mac OS X ships with the Jar Launcher application, the end user needs only double click on the jar file and the application will launch.JavaSoundDemo.jar
with the command jar xvj JavaSoundDemo.jar
. Here's the file META-INF/MANIFEST.MF
.runide.sh
can be run from the command line like this.sh runide.sh -jdkhome /Library/Java/Home
NetBeansLauncher
.NetBeansLauncher
that is included in the generic NetBeans download is a good next step. You will see how the team took it farther in the next section. On a Mac OS X computer you can double click on the macosx_launcher.dmg
file inside of the bin
directory. This is a disk image. Drag the NetBeansLauncher
from the expanded disk image back into the bin
directory. Now double click on the NetBeansLauncher
. The ReadMe file that was also in the disk image provides the following information about usage.When launched for the first time, NetBeansLauncher needs to find NetBeans root directory. First it looks into NetBeansLauncher.app itself. If it does not find NetBeans root directory there user must specify NetBeans root directory manually.
NetBeansLauncher
, they need to navigate to the netbeans
directory. After that, double clicking on the NetBeansLauncher
starts up the NetBeans IDE as if it were any other native Mac OS X application.NetBeansLauncher
application anywhere on your hard drive. Double click on it and the NetBeans IDE starts right up.NetBeansLauncher
instructions that says in order to locate the NetBeans root directory, 'First it looks into NetBeansLauncher.app itself.' This implies that NetBeansLauncher
is a directory with the name 'NetBeansLauncher.app'. In the mounted disk image, either right click or Ctrl-click on the NetBeansLauncher icon and choose to 'Show Package Contents'.Contents
directory with an XML file named info.plist
, a text file named PkgInfo, a MacOS directory, and a Resources directory. If you don't have a creator code registered with Apple the PkgInfo text file should contain only the following.Resources
directory.netbeans
package inside of the Resources
subdirectory. This is your key to deploying on Mac OS X. Add in the necessary pieces and then just bundle up your ordinary distribution in the appropriate location. If you have a more flexible build process you should also strip out those pieces that aren't needed for the Mac OS X application such as the Windows executables.Jar Bundler
application to turn jar files into Mac OS X applications. Jar Bundler
is distributed with the other developer tools and is located in Developer/Applications/
. Start it, select the 'Classpath and Files' tab and add the file JavaSoundDemo.jar
.JavaSoundDemo.jar
file again and select JavaSound
from the drop down list. This list is populated by any classes in the jar file containing a main()
method. Accept all of the default settings for the options. You can use the default Java application icon or you can create your own. The icon you see below started as a screen shot of the running Java Sound Demo and was transformed into an icon using the IconComposer
application that is also distributed as part of the developer tools.Jar Bundler
on Mac OS X.JavaSoundDemo.app
. Next, create a subdirectory named Contents
. Inside of Contents
you will need a MacOS
directory with the JavaAPplicationStub
. You can create the PkgInfo
text file and your Info.plist
can also be generated by hand and should contain the following XML.Resources
directory with a Java
subdirectory into which you put the JavaSoundDemo.jar
file. In other words, with the exception of the JavaApplicationStub
and the music.icns
file, everything else can be created on another platform.