====== Java 11 pitfalls ======
===== How to port a Java 8 GUI application to Java 11 =====
- Check the Maven settings.xml: [[https://www-acc.gsi.de/wiki/Applications/DevelopmentClusterUpdateApril19|3.2 in BEL Wiki]]
- Check out the old project from SVN on the asl cluster (e.g. within Netbeans)
- change the parent to de.gsi.cs.cocsco-parent-java-bundle13.0.0-SNAPSHOT
- use latest dependencies for JavaFX (or Harald's libs): org.openjfxjavafx-controls12.0.1org.openjfxjavafx-fxml12.0.1 or de.gsi.lo.bilobi-common-gui-fx1.9.0-SNAPSHOT
- compile should now work on the command line and within NetBeans
- if no LSA or device access is used: the program can now only be executed by the command line, not within NetBeans
- LSA or DeviceAcces: Seems to work out of the box when the new 13.0.0 parent is used.
===== Javadoc error =====
When compiling a project on the command line with 'mvn' a Javadoc error can occur (followed by some warnings):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.1.0:jar (attach-javadocs) on project esr-bpm: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - javadoc: error - The code being documented uses modules but the packages defined in https://docs.oracle.com/javase/8/docs/api/ are in the unnamed module.
[ERROR] /common/home/sd/rhaseitl/lnx/tmp/esr-bpm/src/main/java/de/gsi/lo/bi/esr/bpm/BpmController.java:158: warning: no description for @param
[ERROR] * @param url
[ERROR] ^
**Latest news:**
All solutions below fail sometimes. Then it helps to remove the complete ... section from the .pom file.
**Superlatest news:**
If you need the build section for passing command line argument, the sction can look like this:
org.codehaus.mojoappassembler-maven-plugin-Dmetafactory.service.name.resolvers=de.gsi.bel.ap.japc.ext.devacc.GSIServiceNameResolver-Dde.gsi.aco.sv.japc.useDefaultResolverFirst=false-Dlog4j.configurationFile=https://websvcdev.acc.gsi.de/groups/lobi/config/log4j2.xml-Dcsco.default.property.config.url=https://websvcpro.acc.gsi.de/groups/cscoap/config/
Please note: Neither the plugin for the javadoc trick (see below) nor the plugin that was there before is in the build section.
**This is NOT used anymore:**
org.apache.maven.pluginsmaven-compiler-plugin2.3.211
**Other solutions:**
To solve this, add this to your pom file (be careful if you already have some other plugins within the tag:
...
org.apache.maven.pluginsmaven-javadoc-plugin
...
Sometimes this is not enough and a tag must be changed from exec to java in the nbactions.xml:
org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
change to
org.codehaus.mojo:exec-maven-plugin:1.2.1:java
===== For Mac =====
Useful YouTube video: [[https://www.youtube.com/watch?v=RCdBmPfzeyM|Mac + J11 + NetBeans]]
The pom file one should download does not work anymore, so I pasted it here:
{{ :ds:software:pom.xml.zip |}}
===== Alert Boxes =====
We might need an additional line to set the size of an alert box resizable. Otherwise the Alert Box is displayed too small and nothing can be clicked.
Without alert.setResizable(true);
{{:ds:software:bildschirmfoto_2019-05-09_um_13.36.54.png?400|}}
With alert.setResizable(true);
{{:ds:software:bildschirmfoto_2019-05-09_um_13.36.17.png?400|}}
\\
Code:
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Are you sure?");
alert.setHeaderText("Really exit the application?");
alert.setContentText("Choose your option.");
ButtonType buttonTypeYes = new ButtonType("Yes");
ButtonType buttonTypeNo = new ButtonType("No");
//ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);
alert.setResizable(true); // only with this line the AlertBox is visible
alert.getDialogPane().getChildren().stream().filter(node -> node instanceof Label).forEach(node -> ((Label)node).setMinHeight(Region.USE_PREF_SIZE));
Optional result = alert.showAndWait();
if (result.get() == buttonTypeYes)
{
// exit the application
exit();
}
===== Launching from within NetBeans =====
To start a project directly from within NetBeans, you must edit the parameters in the project properties:
Actions - Run project - Set Properties (adapt to your project settings):
metafactory.service.name.resolvers=de.gsi.bel.ap.japc.ext.devacc.GSIServiceNameResolver
de.gsi.aco.sv.japc.useDefaultResolverFirst=false -classpath %classpath de.gsi.lo.bi.trafos.TrafoMainApp
exec.executable=java
{{:ds:software:bildschirmfoto_2019-05-16_um_10.12.59.png|}}
===== weird look an asl when started via Windows/XWin =====
The dti Joda program showd this weird behaviour:
* when started via ssh -X, the GUI looked as intended
* when started via XWin32/XDMCP on windows, the GUI was squeezed together (see screenshots)
As a quick solution, the window has been made resizable in the code. Then it looks as intended on all platforms.
not looking good:
{{:ds:software:2019-05-21_09-50-14_asl744.acc.gsi.de.png|}}
looking good:
{{:ds:software:2019-05-21_09-48-20_asl744.acc.gsi.de.png|}}