Reputation: 499
I've been trying to create a .app for Mac using Oracle's appbundler. I created a sample javaFX code with just a button displayed on the scene. The following is my Main class.
Main.java
package app;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class Main extends Application {
private void init(Stage primaryStage) throws Exception {
Button root = new Button("Hello world!");
Scene scene = new Scene(root,150,50);
primaryStage.setScene(scene);
}
@Override
public void start(Stage primaryStage) {
try {
init(primaryStage);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
When I run this from eclipse it works. So I created an ant script to bundle the application:
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="builder" default="build-app" basedir=".">
<property name="src" value="src" />
<property name="build" value="build" />
<property name="lib" value="lib" />
<!-- Target init -->
<target name="init" description="generate build folder">
<delete dir="${build}" />
<mkdir dir="${build}" />
</target>
<!-- Build app -->
<target name="build-app" depends="init">
<echo>Building files</echo>
<javac destdir="${build}" includeantruntime="true">
<src path="${src}/app" />
</javac>
</target>
<!-- Build app -->
<target name="gen-jar" depends="build-app">
<jar destfile="${lib}/app.jar" basedir="${build}/app"/>
</target>
<!-- BUNDLE APP -->
<target name="bundle-sample" depends="gen-jar">
<taskdef name="bundleapp"
classname="com.oracle.appbundler.AppBundlerTask"
classpath="lib/appbundler-1.0.jar" />
<bundleapp outputdirectory="."
name="sample"
displayname="sample"
identifier="sample"
mainclassname="app.Main">
<!-- jdk directory -->
<runtime dir="/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home"/>
<classpath file="lib/app.jar" />
</bundleapp>
</target>
</project>
I can now successfully build the ant script by running:
ant bundle-sample
Although when i run the app I get the following error
open sample.app
LSOpenURLsWithRole() failed with error -10810 for the file sample.app
Does anybody know what's wrong with the build.xml?
Upvotes: 2
Views: 428
Reputation: 10640
As you are using Eclipse anyway I'd advise you to use the e(fx)clipse plugin and then follow this tutorial. It worked for me.
http://code.makery.ch/library/javafx-8-tutorial/part7/
Good luck Michael
Upvotes: 2