Reputation: 21
I am trying to bundle a java application on windows for mac using appbundler-1.0.jar and Ant with an embedded jre 7.
This is the build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="AppName" default="default" basedir=".">
<property environment="env" />
<taskdef
name="bundleapp"
classname="com.oracle.appbundler.AppBundlerTask"
classpath="lib/appbundler-1.0.jar" />
<target name="bundle-AppName">
<bundleapp
outputdirectory="dist"
name="AppName"
displayname="AppName"
identifier="com.hmf.AppName"
icon="files\logo48.icns"
shortversion="1.0"
mainclassname="hmf.AppName.app">
<classpath file="files/AppName.jar" />
<librarypath dir="pathToLibraries" />
<option value="-Dapple.laf.useScreenMenuBar=false"/>
<option value="-XstartOnFirstThread=true"/>
<option value="-Dcom.apple.macos.useScreenMenuBar=false"/>
<option value="-Dcom.apple.smallTabs=true"/>
<option value="-Dsun.java2d.d3d=false"/>
<option value="-Derby.storage.pageSize=8192"/>
<option value="-Djava.library.path=lib/swt.jar:lib"/>
<option value="-Xmx1400M"/>
</bundleapp>
</target>
</project>
I then copy jre 7 for mac to PlugIns directory under AppName.app. (I cant make it work with the runtiime tag)
But when I try to run the application I get: "Unable to load Java Runtime Environment".
When OS use system jre it works but I want to be able to use the embedded jre.
Also see:
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
Application is using Java 6 from Apple instead of Java 7 from Oracle on Mac OS X?
Upvotes: 2
Views: 6402
Reputation: 430
I've solved the issue with my "Unable to load Java Runtime Environment" by using an installed JDK as the jre to be embedded within my app. I was until now using a jre unzipped within a user folder. with the JDK I set the environment variable at the command line
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home
I then used the
<runtime dir="${env.JAVA_HOME}" />
and it worked as the jre gets installed under the Plugins directory as it should i.e no need to manually copy jre
Upvotes: 1