8

I am trying to run a simple program using JavaFX 11 with Eclipse, but I am getting this error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module format not recognized: D:\javafx-sdk-11.0.2\lib\src.zip

I followed these instructions. This is where JDK & JavaFX are located:

D:\javafx-sdk-11.0.2\
C:\Program Files\Java\jdk-11.0.2

The VM arguments are:

--module-path "D:\javafx-sdk-11.0.2\lib" --add-modules=javafx.controls,javafx.fxml

Please help to identify and rectify the problem. (I tried several things as suggested below, but nothing seems to be working.)

Sae1962
  • 1,122
  • 15
  • 31
Ali
  • 479
  • 4
  • 11
  • Please provide a link to the directions you tried to follow. – Stephen Mar 07 '19 at 06:27
  • This is the link: https://stackoverflow.com/questions/52144931/how-to-add-javafx-runtime-to-eclipse-in-java-11 – Ali Mar 07 '19 at 06:32
  • If you do not have a `module-info.java` file, `--module-path` will not work. If removing the VM arguments does not fix your issue, show your run configuration and add the command line to your question (in the run configuration there is a _Show Command Line_ button for that. – howlger Mar 07 '19 at 06:51
  • I removed VM arguments now I have new error:Error occurred during initialization of boot layer java.lang.module.FindException: Module format not recognized: C:\Program Files\Java\javafx-sdk-11.0.2\lib\src.zip – Ali Mar 07 '19 at 06:57
  • 1
    Contrary to what @howlger said, using `--module-path` _will_ work even if you don't have a `module-info.java`. The error's message makes me think the problem is related to having a space in the value of your `--module-path` (i.e. "_Program Files_"). Try surrounding the value in quotes (`"`) if you haven't already (using the original setup you had). – Slaw Mar 07 '19 at 07:03
  • 2
    Also, it is often best to [edit] your question to provide more information rather than using one or more comments. – Slaw Mar 07 '19 at 07:04
  • Yes, @Slaw is correct: `--module-path` will work even if you don't have a `module-info.java`. But the problem is that `--module-path` is specified by Eclipse (`-p` is the shortcut for `--module-path`). – howlger Mar 07 '19 at 07:23
  • @Slaw, thanks, I made the changes and edited the question as well. Thanks. – Ali Mar 07 '19 at 07:38
  • @howlger thanks, also i included the command line in the question as well. – Ali Mar 07 '19 at 07:46
  • @Ali Does in the project's _Java Build Path_ moving JavaFX from the _Modulepath_ to the _Classpath_ and removing the VM arguments fix your issue? Currently you have specified the modulepath twice, via the VM argument `--module-path` and in Eclipse via _Java Build Path_ (in the command line as `-p`) incorrectly containing `src.zip`. If you want to keep JavaFX on the modulepath without a `module-info.java` file (which is not recommended), you explicit have to add the required module(s), e. g. via `--add-modules=ALL-SYSTEM`. – howlger Mar 07 '19 at 09:03
  • @howlger, I removed JavaFX from Modulepath and added to Classpatth and also removed VM arguments, then I get this error:Error: JavaFX runtime components are missing, and are required to run this application. Do I need to add module-info.java file to solve the problem? – Ali Mar 07 '19 at 09:11

1 Answers1

6

While making user library for JavaFX 11, I was adding all the files including .jar and the src.zip file.

However, now that I didn't select the src.zip file, it's working fine. :-)

This is the VM argument:

--module-path "F:\javafx-sdk-11.0.2\lib" --add-modules=javafx.controls,javafx.graphics,javafx.fxml

(Yup, on this PC, I used the F: drive.)

Thanks all for your support!

Sae1962
  • 1,122
  • 15
  • 31
Ali
  • 479
  • 4
  • 11
  • _Note: You_ shouldn't _need to include `javafx.graphics` in the `--add-modules` command as the `javafx.controls` module transitively requires the `javafx.graphics` module. However, including it in the command doesn't hurt._ – Slaw Mar 11 '19 at 04:40