Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Main.class found in top-level directory (unnamed package not allowed in module)

Tags:

Trying to update an application to Java 11 and after sorting through hell with modules I thought I had got rid of all the red errors and now I'm getting this one I've never seen before:

enter image description here

Looking around I've seen people suggest it is possible to do with the application structure:

enter image description here

or the module-info.java file:

enter image description here

Can anybody see what I need to do to get rid of this?

Edit: Error after moving Main.java to a package called 'main' and trying to run it:

enter image description here

like image 732
AlwaysNeedingHelp Avatar asked Sep 23 '18 20:09

AlwaysNeedingHelp


1 Answers

In order for a JavaFx to launch your app, it needs access to its main class, so you need to export the package in which the main class is located.

Add export declaration to module-info:

module Game.main {
    ...

    exports main;
}
like image 95
Guest 21 Avatar answered Oct 13 '22 00:10

Guest 21