Home > Java > javaTutorial > How Can I Integrate JavaFX into Eclipse Using Java 11?

How Can I Integrate JavaFX into Eclipse Using Java 11?

Linda Hamilton
Release: 2024-11-08 20:42:02
Original
1046 people have browsed it

How Can I Integrate JavaFX into Eclipse Using Java 11?

Adding JavaFX to Eclipse in Java 11

Due to JavaFX's exclusion from Java 11, getting it up and running in Eclipse requires a specific setup. Here's a comprehensive guide:

Prerequisites:

  • Install Eclipse 2018-09
  • Install JDK 11
  • Download JavaFX 11 ea

Steps:

  1. Add Java 11 JRE to Eclipse:

    Navigate to Eclipse > Window > Preferences > Java > Installed JREs > Add and select the installed Java 11 JRE.

  2. Create User Library for JavaFX:

    Go to Eclipse > Window > Preferences > Java > Build Path > User Libraries > New. Name it JavaFX11 and add the jars from the lib folder of JavaFX 11-ea.

  3. Create Java Project:

    Create a new Java project, ensuring Java 11 is selected. Include the JavaFX11 library in its module path.

  4. Add HelloFX Application:

    Create a package named javafx11 and add the following Java class:

    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    
    public class HelloFX extends Application {
        public static void main(String[] args) { launch(); }
           
        @Override
        public void start(Stage stage) {
            Scene scene = new Scene(new StackPane(new Label("Hello, JavaFX 11")), 300, 200);
            stage.setScene(scene);
            stage.show();
        }
    }
    Copy after login
  5. Add Runtime Arguments:

    Edit the project's Run Configuration and add the following VM arguments:

    • --module-path C:UsersDownloadsjavafx-sdk-11lib
    • --add-modules=javafx.controls
  6. Run the Project:

    Run the HelloFX project, and it should display a simple message.

The above is the detailed content of How Can I Integrate JavaFX into Eclipse Using Java 11?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template