السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
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
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
- Netbeans 11 (Support Java 12)
- JDK 12 (disini menggunakan bellsoft liberica OpenJDK 12)
- JavaFX 12 SDK for windows
- JavaFX Scene Builder
Tutorial ini tidak menggunakan Maven atau Gradle.
- 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) - 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 - Download JavaFX 12 JDK for Windows form gluon
https://gluonhq.com/products/javafx/
Extract folder - Download JavaFX Scene builder and install
https://gluonhq.com/products/scene-builder/ - Open Apache Netbeans 11 in netbeans -> bin and double click netbeans.exe for windows 32 bit or netbeans64.exe for windows 64 bit
- 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 - 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 - Create java application not javafxappication !!
Click Menu tab File -> New Project -> Java with Ant -> Java Application
Example Project name "HelloFX" -> Finish - 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. - Add module JavaFX 12
Go to project (HelloFX) -> right click -> Properties -> Libraries -> Class-path -> + -> Add Library -> Select JavaFX12 -> OK - Add empty FXML
expand HelloFX -> expand Source Packages -> right click hellofx -> new -> empty FXML -> fill FXML Name = MainFXML -> next-> check use java controller -> finish - Open HelloFX.java and delete all code and replace with code
- Open MainFXML.fxml and create label and button (example)
- Right click project (HelloFX) -> click on Properties -> Run -> and add these VM options: and click OK
- Run Project
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);
}
}
--add-modules=javafx.controls,javafx.fxml
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