Here's what you have to do:
- Package the app as you would normally, using the process linked above.
- Right-click the produced app and select Show Package Contents. Then enter the Contents folder.
- Enter the Plugins folder. This contains the JRE. Delete it.
- Replace the deleted JRE with the copy stored on your computer. It can be found in Your Hard Drive < Library < Java < Java Virtual Machines. Just copy the version you need if there are multiple folders in there.
- Go back to the Contents folder and enter the MacOS folder. This contains the shell that runs your Jar file. Open the executable file that's in there with a text editor and delete everything. Replace it with this:
#!/bin/sh
# Constants
APP_JAR="YOURAPP.jar"
APP_NAME="YOURAPP"
VM_ARGS=""
# Set the working directory
DIR=$(cd "$(dirname "$0")"; pwd)
# Set java location
_java="../PlugIns/jdk1.8.0_05.jdk/Contents/Home/bin/java"
# Move to correct directory
cd $DIR
# Run the application
exec $_java $VM_ARGS -Dapple.laf.useScreenMenuBar=true -Dcom.apple.macos.use-file-dialog-packages=true -Xdock:name="$APP_NAME" -Xdock:icon="$DIR/../Resources/ICON.icns" -cp ".;$DIR;" -jar "$DIR/../Java/$APP_JAR"
In the above, substitute YOURAPP for the name of your jar file, jdk1.8.0_05
for whichever version of Java you added in step 4, and ICON for the name of your app's icon, if it has one.
- If you want to change the app's icon from the standard Java logo, go back to Contents and add your own .icns file to the Resources folder.
There you have it! The app should run as intended, preloader and all.