Table of Contents

Java 11 pitfalls

How to port a Java 8 GUI application to Java 11

  1. Check the Maven settings.xml: 3.2 in BEL Wiki
  2. Check out the old project from SVN on the asl cluster (e.g. within Netbeans)
  3. change the parent to
    	<parent>
    		<groupId>de.gsi.cs.co</groupId>
    		<artifactId>csco-parent-java-bundle</artifactId>
    		<version>13.0.0-SNAPSHOT</version>
    	</parent>
  4. use latest dependencies for JavaFX (or Harald's libs):
      		<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>
      

    or

    		  
      <dependency>
    	<groupId>de.gsi.lo.bi</groupId>
    	 <artifactId>lobi-common-gui-fx</artifactId>
    	 <version>1.9.0-SNAPSHOT</version>
      </dependency>
      
  5. compile should now work on the command line and within NetBeans
  6. if no LSA or device access is used: the program can now only be executed by the command line, not within NetBeans
  7. 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

 <build> ... </build>

section from the .pom file.

Superlatest news: If you need the build section for passing command line argument, the sction can look like this:

<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>

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:

<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>

Other solutions: To solve this, add this to your pom file (be careful if you already have some other plugins within the <build> tag:

  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <source>8</source>
        </configuration>

      </plugin> 
    </plugins>
  </build>
  ...

Sometimes this is not enough and a tag must be changed from exec to java in the nbactions.xml:

<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>

change to

<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:java</goal>

For Mac

Useful YouTube video: Mac + J11 + NetBeans The pom file one should download does not work anymore, so I pasted it here:

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);

With

alert.setResizable(true);


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();
		}

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

weird look an asl when started via Windows/XWin

The dti Joda program showd this weird behaviour:

As a quick solution, the window has been made resizable in the code. Then it looks as intended on all platforms.

not looking good:

looking good: