Do I need to run my main
method inside a module or outside?
I am new in using the modular system of Java. I am trying create a simple program with JavaFX in Java 10, since it is the last version of Java that supports JavaFX.
I imported the necessary dependencies on my module-info.java
for JavaFX which shows just a simple window.
sample.fxml
code:
<?import javafx.scene.layout.GridPane?>
<GridPane fx:controller="com.gui.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>
When I build my code it says:
Warning:(4, 27) java: module not found: com.main
When I try to run my code I get:
Exception in Application constructor Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:941)
Can anyone give me advice for this, or somehow a real world application advice about creating projects with the modular system.
I have attached a pair of screenshots below.
Build Warning :
Runtime Failure :