Eclipse IDE does not run Java application after modification of module name

Viewed 482

I realized a Java 9 "Hello World" program in Eclipse Version: 2020-09 (4.17.0) using the following module-info.java

module org.example.test { }

I then modified module-info.java thus changing the module name of the application:

module org.example.modified { }

When I started the application with the modified module-info.java with Run As -> Java Application I got the following error message:

Error occurred during initialization of boot layer java.lang.module.FindException: Module org.example.test not found

After displaying the command line Eclipse is using to start the application (via Run As->Run Configurations-> Show Command Line) I got the following:

C:\Program Files\Java\jdk-15.0.1\bin\javaw.exe -Dfile.encoding=Cp1252
-p "D:\Test\bin" -m org.example.test/org.example.Start

Obviously the module name has not been updated in the command line.

Any hints on how to have the command line / run configuration properly updated after a change of the module name ?

1 Answers

Seems to be an error in Eclipse, that the Run Configuration isn't updated with the new module name.

Two workarounds:

  • Delete the Run Configuration, the do Run As > Java Application again.

    Easiest solution if you hadn't customized the Run Configuration.

  • Edit the Run Configuration:

    • Change the Main class name, e.g. add an X at the end.
    • Click Apply to save the change.
    • Click Search and select the class.
    • Click Apply to save the change.

    Seemed to work for me.

Related