Sunday, October 21, 2012

Jar Bundler - MAC OS X

I used to bundle all the jar files using JarBundler we get with Xcode. However, this is not working with JDK 7. Previously, I used it with JDK 1.6 (Apple Java 6) and then made a package file with Package Maker. Since JDK 7 is from Oracle, it cannot be used with Apple's tools like Xcode. Oracle cannot support or use, tools like Xcode or JarBundler as they use non-public APIs.

Therefore, apps using JDK 7 must be bundled with appbundler or javafxpacker. But according to Oracle "JavaFX applications can only be packaged on Mac as desktop applications and cannot be deployed on Mac, because there is no standalone JRE or JavaFX Runtime". Similarly, Launch4j version for Mac could only be used to create .exe files and cannot be deployed on Mac.

So how to do it? It seems the only option is appbundler (http://java.net/projects/appbundler).


In the terminal with the appbundler, you may get the following error ($ant bundle-button):

BUILD FAILED
/Users/me/Downloads/components-ButtonDemoProject/build.xml:16: java.nio.file.NoSuchFileException: /Users/nus/Downloads/components-ButtonDemoProject/Info.plist
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:520)
at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:252)
at java.nio.file.Files.copy(Files.java:1225)
at com.oracle.appbundler.AppBundlerTask.copy(AppBundlerTask.java:566)
at com.oracle.appbundler.AppBundlerTask.copyRuntime(AppBundlerTask.java:357)
at com.oracle.appbundler.AppBundlerTask.execute(AppBundlerTask.java:290)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)


It happens because JAVA_HOME is not set properly. Therefore, it can be set by in the terminal:
export JAVA_HOME=`/usr/libexec/java_home --version 1.7.0_10`
or
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home

1.7.0_10 is the JDK version I am using.

Thus, now I am getting BUILD SUCCESSFUL when run $ant bundle-button
You will get .app now.


Reference:
http://docs.oracle.com/javafx/2/installation_2-1/javafx-installation-mac.htm
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

4 comments:

  1. Thank for the post, is very clear and useful, it works well with the demo project I think because is a Swing app but unfortunately don't work for me with JavaFx app.

    ReplyDelete
  2. Hi can u send how to convert .jar file to .dmg file.. nad please send jar Bundler code because if i download any software means main files is not avaialble

    ReplyDelete
  3. Thanks for the post! Saved my debugging effort :-)

    ReplyDelete
  4. My Experience...: Jar Bundler - Mac Os X >>>>> Download Now

    >>>>> Download Full

    My Experience...: Jar Bundler - Mac Os X >>>>> Download LINK

    >>>>> Download Now

    My Experience...: Jar Bundler - Mac Os X >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete