Printfriendly

Create Project Java 12 + JavaFX using Apache Netbeans

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ

Java 12 merupakan kelanjutan dari Java 11, Java 12 sendiri dirilis oleh oracle sekitar 19 maret 2019. sama seperti Java 11, didalam Java 12 tidak include JavaFX dan juga Java EE. karenanya kita memerlukan library JavaFX untuk menggunakannya








Berikut tool dan bahan yang diperlukan
  1. Netbeans 11 (Support Java 12)
  2. JDK 12 (disini menggunakan bellsoft liberica OpenJDK 12)
  3. JavaFX 12 SDK for windows
  4. JavaFX Scene Builder
Tutorial ini tidak menggunakan Maven atau Gradle.
  1.  Download Apache Netbeans 11 from this link
    https://www.apache.org/dyn/closer.cgi/incubator/netbeans/incubating-netbeans/incubating-11.0/incubating-netbeans-11.0-bin.zip
    Extract and then open folder netbenas -> bin. (Dont Open)
  2. Download JDK 12 ,we can use OpenJDK from Bellsoft
    https://bell-sw.com/pages/java-12.0.1/
    Choose 32 bit or 64 bit and then click Download MSI (also available for Raspberry pi), and then install
  3. Download JavaFX 12 JDK for Windows form gluon
    https://gluonhq.com/products/javafx/
    Extract folder
  4. Download JavaFX Scene builder and install
    https://gluonhq.com/products/scene-builder/
  5. Open Apache Netbeans 11 in netbeans -> bin and double click netbeans.exe for windows 32 bit or netbeans64.exe for windows 64 bit
  6. Add Java 12 (OpenJDK 12 from bellsoft) to Netbeans
    Click menu tab Tools -> Options -> Java -> Java Shell -> Manage -> Add Platform -> Select Java Standart Edition -> Next -> Browse to C:\Program Files\BellSoft\LibericaJDK-12 or Browse to C:\Program Files (x86)\BellSoft\LibericaJDK-12
    Click Finish -> Close -> OK
  7. Create Global Library for JavaFX SDK 12
    Under Menu tab Tools -> Libraries -> New Library.
    Name it JavaFX12 and include all the jars under the lib folder from JavaFX 12 except src.zip
  8. Create java application not javafxappication !!
    Click Menu tab File -> New Project -> Java with Ant -> Java Application
    Example Project name "HelloFX" -> Finish
  9. Make sure your project is configured to run with JDK 12
    Go to project (HelloFX) -> right click -> Properties -> Libraries -> Java Platform, and set it to JDK 12.
  10. Add module JavaFX 12
    Go to project (HelloFX) -> right click -> Properties -> Libraries -> Class-path -> + -> Add Library -> Select JavaFX12 -> OK
  11. Add empty FXML
    expand HelloFX -> expand Source Packages -> right click hellofx -> new -> empty FXML -> fill FXML Name = MainFXML -> next-> check use java controller -> finish
  12. Open HelloFX.java and delete all code and replace with code
  13. package hellofx;
    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    
    public class HelloFX extends Application {
    
        @Override
        public void start(Stage primaryStage) throws Exception{
            Parent root = FXMLLoader.load(getClass().getResource("MainFXML.fxml"));
            primaryStage.setTitle("Hello World");
            primaryStage.setScene(new Scene(root));
            primaryStage.show();
        }
    
    
        public static void main(String[] args) {
            launch(args);
        }
    }

  14. Open MainFXML.fxml and create label and button (example)
  15. Right click project (HelloFX) -> click on Properties -> Run -> and add these VM options: and click OK
  16. --add-modules=javafx.controls,javafx.fxml

  17. Run Project
Good Luck
Semoga bermanfaat
وَعَلَيْكُمْ السَّلاَمُ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ

0 komentar "Create Project Java 12 + JavaFX using Apache Netbeans", Baca atau Masukkan Komentar

Post a Comment

Jika artikel ini bermanfaat bisa dishare gan, tapi ingat selalu cantumkan sumber jika ingin copas artikel ini