User Tools

Site Tools


ds:software:java11

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ds:software:java11 [2019/05/07 13:05]
rhaseitl created
ds:software:java11 [2019/05/21 10:14] (current)
rhaseitl [weird look an asl when started via Windows/XWin]
Line 2: Line 2:
  
 ===== How to port a Java 8 GUI application to Java 11 ===== ===== 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 <code> <parent>
 + <groupId>de.gsi.cs.co</groupId>
 + <artifactId>csco-parent-java-bundle</artifactId>
 + <version>13.0.0-SNAPSHOT</version>
 + </parent></code>
 +  - use latest dependencies for JavaFX (or Harald's libs): <code>
 +  <dependency>
 + <groupId>org.openjfx</groupId>
 + <artifactId>javafx-controls</artifactId>
 + <version>12.0.1</version>
 + </dependency>
 +
 + <dependency>
 + <groupId>org.openjfx</groupId>
 + <artifactId>javafx-fxml</artifactId>
 + <version>12.0.1</version>
 + </dependency>
 +  </code>  or  <code>   
 +  <dependency>
 + <groupId>de.gsi.lo.bi</groupId>
 + <artifactId>lobi-common-gui-fx</artifactId>
 + <version>1.9.0-SNAPSHOT</version>
 +  </dependency>
 +  </code>
 +  - 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):
 +<code>
 +[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]      ^
 +</code>
 +
 +**Latest news:**
 +All solutions below fail sometimes. Then it helps to remove the complete <code> <build> ... </build></code> section from the .pom file.
 +
 +**Superlatest news:**
 +If you need the build section for passing command line argument, the sction can look like this:
 +<code>
 +<build>
 +<plugins>
 +<plugin>
 + <groupId>org.codehaus.mojo</groupId>
 + <artifactId>appassembler-maven-plugin</artifactId>
 + <configuration>
 + <programs>
 + <program>
 + <jvmSettings>
 + <extraArguments>
 + <extraArgument>-Dmetafactory.service.name.resolvers=de.gsi.bel.ap.japc.ext.devacc.GSIServiceNameResolver</extraArgument>
 + <extraArgument>-Dde.gsi.aco.sv.japc.useDefaultResolverFirst=false</extraArgument>
 + <extraArgument>-Dlog4j.configurationFile=https://websvcdev.acc.gsi.de/groups/lobi/config/log4j2.xml</extraArgument> 
 + <extraArgument>-Dcsco.default.property.config.url=https://websvcpro.acc.gsi.de/groups/cscoap/config/</extraArgument> 
 + </extraArguments>
 + </jvmSettings>
 + </program>
 + </programs>
 + </configuration>
 +</plugin>
 +</plugins>
 +</build>
 +</code>
 +
 +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:**
 +<code>
 +<plugin>
 + <groupId>org.apache.maven.plugins</groupId>
 + <artifactId>maven-compiler-plugin</artifactId>
 + <version>2.3.2</version>
 + <configuration>
 + <source>11</source>
 + <target>11</target>
 + </configuration>
 +</plugin>
 +</code>
 +
 +
 +
 +**Other solutions:**
 +To solve this, add this to your pom file (be careful if you already have some other plugins within the <build> tag:
 +
 +<code>
 +  ...
 +  <build>
 +    <plugins>
 +      <plugin>
 +        <groupId>org.apache.maven.plugins</groupId>
 +        <artifactId>maven-javadoc-plugin</artifactId>
 +        <configuration>
 +          <source>8</source>
 +        </configuration>
 +
 +      </plugin> 
 +    </plugins>
 +  </build>
 +  ...
 +
 +</code>
 +
 +Sometimes this is not enough and a tag must be changed from exec to java in the nbactions.xml:
 +<code><goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal></code>
 +change to
 +<code><goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:java</goal></code>
 +
 +===== 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 <code>alert.setResizable(true);</code>
 +{{:ds:software:bildschirmfoto_2019-05-09_um_13.36.54.png?400|}}
 +
 +With <code>alert.setResizable(true);</code>
 +{{:ds:software:bildschirmfoto_2019-05-09_um_13.36.17.png?400|}}
 +\\
 +Code:
 +
 +<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<ButtonType> result = alert.showAndWait();
 +
 + if (result.get() == buttonTypeYes)
 + {
 + // exit the application
 + exit();
 + }
 +
 +</code>
 +
 +===== 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):
 +<code>
 +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
 +</code>
 +
 +{{: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|}}
ds/software/java11.1557227119.txt.gz · Last modified: 2019/05/07 13:05 by rhaseitl