Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse/Java9: how to access internal javafx packages?

My context:

  • Eclipse IDE for Java Developers, Version: Oxygen.1a Release (4.7.1a), Build id: 20171005-1200oxygen
  • jdk9.0.1
  • win10

Something simple like:

import com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler;

import javafx.application.Application;
import javafx.stage.Stage;

public class ImportCom extends Application {

    @Override
    public void start(Stage arg0) throws Exception {
        new LambdaMultiplePropertyChangeListenerHandler();

    }

}

won't compile due to

The type com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler is not accessible

What to do?

looks similar but now for internal classes ;) Had been compiling until patch 530 of the beta9 support but not after - so keeping that oldish oxygen as a gold treasure ...

Note: cross-posted to eclipse forum

Edit:

Just checked that the behavior of javac on the commandline:

C:\Users\kleopatra\ox-1a-64\dummy\src>\java\jdk\190-64\bin\javac first\ImportCom.java
first\ImportCom.java:3: error: package com.sun.javafx.scene.control is not visible
import com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler;
                           ^
  (package com.sun.javafx.scene.control is declared in module javafx.controls, which does not export it to the unnamed module)
1 error

The error is similar to the one in Eclipse. Works fine with --add-exports:

C:\Users\kleopatra\ox-1a-64\dummy\src>\java\jdk\190-64\bin\javac --add-exports=javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED first\ImportCom.java

So the question boils down to: where/how to configure Eclipse such that it compiles access to internal classes just the same way as javac?

like image 363
kleopatra Avatar asked Nov 13 '17 11:11

kleopatra


People also ask

What method is invoked to display a stage in JavaFX?

A stage is displayed by invoking the show() method on the stage. 14.4 What is the output of the following JavaFX program?


2 Answers

  1. In Project > Properties: Java Build Path, Libraries tab, select the node Modulepath/JRE System Library[JavaSE-9]/Is modular and click Edit...
  2. In the Module Properties dialog, in the Details tab, in the Added exports section click Add... and enter the following:
    • Source module: javafx.controls
    • Package: com.sun.javafx.scene.control
  3. Click OK twice to close the Add-exports configuration and the Module Properties dialogs and Apply and Close to close the Properties dialog

enter image description here

like image 177
howlger Avatar answered Oct 01 '22 09:10

howlger


Well, it's a bit hidden:

  • open Java Build Path dialog of the project
  • select Libraries tab
  • select isModular entry
  • use the Edit... button to open the module properties dialog
  • select Details tab
  • create all required entries with the Add.. button

If you have installed the Beta plugin for Java 9 support - uninstall. Make sure the latest Java 9 support plugin is installed.

like image 20
wzberger Avatar answered Oct 01 '22 07:10

wzberger