I have been using javaFX for a while now, but a day ago when I crated a new project I noticed that there is a new file created automatically with the name (module-info.java) in the default package, and I can not even delete it!!.
the following code is written there:
module prog0 { requires javafx.controls; opens application to javafx.graphics, javafx.fxml; }
unfortunatily all lines has errors
1ST line : Syntax error on token “module”, interface expected
2nd line : Syntax error on token “.”, , expected
3rd line : **Multiple markers at this line
- Syntax error on token "to", = expected - Syntax error on token ".", , expected - Syntax error on token "to", = expected - Syntax error on token ".", , expected**
Advertisement
Answer
The module-info.java file looks pretty typical for modular Java projects (Java 9+). It is usual to require the javafx.controls, and to open your application (here, actually named “application”) to javafx. I think this latter statement pertains to the javafx module needing to be able to look into the module that has the entry point for the program.
But the location of the file seems suspect to me. I’m not up on all the complexities, but I do think the file would be better located directly under the /src directory rather than in a default package. Usually the module-info.java file is the top file folder level and the source code for the program is a child folder.
In other words, the module-info.java file and the /application package file should be in the same folder. At least, that is how things are set up on my javafx programs and modular java programs.
EDIT: I noticed that your Build Path is listing Java 1.5! This Java doesn’t support modules. Modules were introduced in Java 9.