I have been checking other questions about the same topic but i couldn't find the specific answers for me.
We have an old project in Java 8, a JavaFX application that we build for Windows and Mac. I am not an expert of Java projects and the company which develop the app is no longer available.
As Apple requires notarizing the app, we managed to do it. But they recently changed the requirements and now it fails: - The binary uses an SDK older than the 10.9 SDK - The signature does not include a secure timestamp
This is shown for tons of internal libraries (dylib) as well as the Contents/MacOS/App. But this is another problem i will face it in the future. Maybe following these instructions: Notarize existing Java application for MacOS Catalina
The main problem is that we tried to compile the project with Java 11 + JavaFX but now we have problems building the app. Note: in order to do this we simply changed from JDK 8 to JDK 11 as well as downloading and attaching the JavaFX 11.0.2 library.
The first problem was not being able to attach the JavaFX library but we managed to do it from Run/Edit configurations. It fixes the issue but now when trying to launch from Intellij it shows errors like:
Error:(18, 27) java: package netscape.javascript does not exist
Error:(9, 24) java: package org.w3c.dom.html does not exist
java cannot find symbol HTMLAnchorElement
What's the problem here? Have those packages removed from Java 11? Intellij allows me to follow the class and find the content.
In addition, we use Maven for building the app. I have tried editing the configuration and so on, adding the VM options in Build, Execution, Deployment -> Maven -> Runner but when trying to package the app, it doesn't find the JavaFX library:
--module-path /path/to/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml
How am i supposed to load the JavaFX module in Maven?
So at this point i have included the JavaFX library in Intellij but unable to launch from it, and unable to include the JavaFX in Maven.
I appreciate any guidance on this.
EDIT:
I managed to fix the netscape and HTMLAnchorElement errors by replacing the imports by new ones:
import jdk.nashorn.api.scripting.JSObject;
Element anchorElement = (Element)event.getCurrentTarget();
And fixed the issue with javafx in maven by adding this in pom.xml file:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>11</version>
</dependency>
I can launch the app from Intellij but when trying to package it via Maven, I got this:
Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:deploy. Cause: The name is undefined
Related to this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<configuration>
<target name="build-app">
<ant antfile="./javafx.build.xml"/>
</target>
</configuration>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
And this is the javafx.build.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="create-app" name="AppName" xmlns:fx="javafx:com.sun.javafx.tools.ant" xmlns:if="ant:if"
xmlns:unless="ant:unless">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath=".;${java.home}/../lib/ant-javafx.jar"/>
<condition property="onmac">
<os family="mac"/>
</condition>
<condition property="onwin">
<os family="windows"/>
</condition>
<target name="create-app" description="create jar file fx" if="os.name">
<echo message="Ant creates javafx app" />
<fx:deploy width="800" height="600" outdir="target/dist" outfile="App" nativeBundles="image" version="1.4.5">
<fx:info title="App Name">
<fx:icon href="installable/mac/logo.icns" kind="default" if:set="onmac" ></fx:icon>
<fx:icon href="src/main/resources/resources/logo_256.ico" kind="default" if:set="onwin"></fx:icon>
</fx:info>
<fx:application name="App Name" mainClass="recorder.DesktopRecorder" />
<fx:resources>
<fx:fileset dir="target/app-module-1.4.5-distribution" includes="*"/>
</fx:resources>
</fx:deploy>
<exec executable="./installable/mac/create-dmg.sh" if:set="onmac"/>
<exec executable="C:\Program Files (x86)\Inno Setup 5\ISCC" if:set="onwin">
<arg value="installable/windows/innosetup_prod.iss" />
</exec>
</target>
I included the ant-javafx.jar file in the project and changed to this:
classpath="./ant-javafx.jar"
But it still failed when creating the Apple "app" file:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project app-module: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /path/to/app/javafx.build.xml:24: Error: Bundler "Mac Application Image" (mac.app) failed to produce a bundle.
[ERROR] around Ant part ...... @ 4:38 in /path/to/app/target/antrun/build-build-app.xml