FXMLのテストアプリケーションが実行できません、助けてください!
エラーメッセージは下記のとおりです。
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls.jmod not found
該当のソースコード
エクリプスではエラーマークなどはなかったので問題がないように思います(コピペです)。
参考サイト:http://nobotta.dazoo.ne.jp/blog/?p=1335
Main
package com.nobotta; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { try { BorderPane root = (BorderPane)FXMLLoader.load(getClass().getResource("FxTest.fxml")); Scene scene = new Scene(root,400,400); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { launch(args); } }
FxTestController
package com.nobotta; import java.net.URL; import java.util.ResourceBundle; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.input.MouseEvent; public class FxTestController implements Initializable{ @FXML private TextField txtName; @FXML private Label lblAnswer; @Override public void initialize(URL location, ResourceBundle resources) { } @FXML private void btnOK_onClick(MouseEvent aEvent) { System.out.println("btnOK_onClick"); lblAnswer.setText(txtName.getText() + "さん こんにちは"); } @FXML private void mnuClose_onClick(ActionEvent event) { System.out.println("mnuClose_onClick"); Platform.exit(); } }
fxml
<?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <?import javafx.scene.control.Menu?> <?import javafx.scene.control.MenuBar?> <?import javafx.scene.control.MenuItem?> <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.RowConstraints?> <BorderPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1" fx:controller="com.nobotta.FxTestController"> <center> <AnchorPane prefHeight="300.0" prefWidth="400.0" BorderPane.alignment="CENTER"> <children> <BorderPane prefHeight="300.0" prefWidth="400.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <center> <GridPane BorderPane.alignment="CENTER"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> </columnConstraints> <rowConstraints> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> </rowConstraints> <children> <Label text="名前を入力してください" /> <TextField fx:id="txtName" GridPane.columnIndex="1" /> <Label text="ボタンをクリックしてください" GridPane.rowIndex="1" /> <Button mnemonicParsing="false" onMouseClicked="#btnOK_onClick" text="OK" GridPane.columnIndex="1" GridPane.rowIndex="1" /> <Label fx:id="lblAnswer" GridPane.columnIndex="1" GridPane.rowIndex="2" /> </children> </GridPane> </center> </BorderPane> </children> </AnchorPane> </center> <top> <MenuBar BorderPane.alignment="CENTER"> <menus> <Menu mnemonicParsing="false" text="ファイル"> <items> <MenuItem mnemonicParsing="false" onAction="#mnuClose_onClick" text="閉じる" /> </items> </Menu> </menus> </MenuBar> </top> </BorderPane>
補足情報
モジュールパスにjavaFXのlibにあるjarファイル8種類とJREシステム・ライブラリーが、クラスパスにJavaFX SDKが追加されています。
VM引数は以下の通りに設定されています
--module-path=C:\Java\javafx-jmods-11.0.2 --add-modules=javafx.controls
Adopt OpenJDK-11.0.8.10-hotspot
EclipseIDE
SceneBuilder
を使用しています。
まだ回答がついていません
会員登録して回答してみよう