0

I am making a Javafx app in IntelliJ. I tried to add "import javafx.scene.web.WebEngine" and "import javafx.scene.web.WebView" to my class. Unfortunately it was not able to import.

I then tried to import the library org.openjfx:javafx-web:17.0.2 in the project libraries, but it perpetually said "Resolving Maven Dependencies" without doing anything. Any time in the past I have added javafx libraries, it was added with no problem, but this library never adds itself. I can not seem to find the correct way to do this. So do I have the incorrect coordinates or is there something wrong with my configuration?

Edit: The library finally did load and showed fine for "org.openjfx:javafx-web:17.0.2" but showed red (error?) for "org.openjfx:javafx-web:mac:17.0.2". Import statement still does not work through I added to the module-info and pom.xml files. So I am still stuck and unsure why it did not work.

jari85
  • 31
  • 3
  • See: https://stackoverflow.com/q/43917036/642706 – Basil Bourque Aug 10 '23 at 13:04
  • Try creating your project using the JavaFX template offered by IntelliJ in the new-project dialog box. I have posted here on this topic. – Basil Bourque Aug 10 '23 at 13:05
  • If your Maven seems confused, delete the `.m2` folder. Clearing that cache often unplugs a stuck Maven installation. – Basil Bourque Aug 10 '23 at 13:07
  • 2
    If your Maven seems confused, delete the `.m2` folder. Clearing that cache often unplugs a stuck Maven installation. Reestablishing a new `.m2` may take a while, depending on the speed of your internet connection. So be patient. – Basil Bourque Aug 10 '23 at 13:13
  • LTS: Version 17.0.8 is current. – trashgod Aug 10 '23 at 17:36
  • @BasilBourque I have had no issue with Maven in the past, and I have downloaded many libraries. Elsewhere I saw someone say Javafx web is deprecated which doesn't make sense, but I was hoping someone could tell me if it is still used, and if the coordinates are correct. I did use a JavaFX template by IntelliJ. Also I don't know where to find this .m2 folder. – jari85 Aug 10 '23 at 17:37
  • JavaFX web is still used and maintained (as are all the JavaFX modules). 17.0.8 is the latest LTS version, 20.0.2 the latest GA version. (Early access for version 21 is planned for September 2023.) You should use the same version of all JavaFX modules. The maven coordinates are correct (basically use the same coordinates as you do for `javafx-controls`, but just change the `artifactId`). The `.m2` folder is usually in your user home directory. Note it's a hidden folder on most systems. What is the error message you get on the `import` statement? Have you added the `javafx.web` module? – James_D Aug 10 '23 at 17:46
  • @James_D For the import statement it doesn't give an error for the library itself but rather for "web" in "import javafx.scene.web.WebEngine;" saying "Cannot resolve symbol web". I don't know why it's not recognizing "web" when it's supposed to be a JavaFX library. I added "requires javafx.web;" to the module-info file but it said it can't find module. I also added the dependency to the pom.xml file. When loading the library, it partially loaded, but showed red for "org.openjfx:javafx-web:mac:17.0.2". – jari85 Aug 10 '23 at 17:58
  • I'd try deleting `.m2/repository/org/openjfx/javafx-web` and its contents; then in IntelliJ right-click on the project, choose "Maven" and "Reload project". That should force a fresh download. – James_D Aug 10 '23 at 18:27
  • 2
    What kind of Mac do you have? Intel or M series? [JavaFX for M series macs may only be stable in later versions](https://stackoverflow.com/questions/75147224/error-initializing-quantumrenderer-no-suitable-pipeline-found/75160212#75160212). Don’t use outdated software. Also provide a pom.xml and module-info that causes the error in the question. – jewelsea Aug 10 '23 at 19:42
  • Yep, I checked some more and [WebKit in JavaFX 17.0.2 was definitely broken on M series macs](https://bugs.openjdk.org/browse/JDK-8281459), and was fixed in later releases. – jewelsea Aug 11 '23 at 05:46
  • @James_D how do I find the .m2 directory? – jari85 Aug 11 '23 at 12:30
  • It's usually in your user home directory. In terminal, try `cd ~/.m2` or using Finder use "Go" -> "Go to folder..." and then `~.m2`. But looking at jewelsea's comments, the solution should be just to change the JavaFX versions to `20.0.1` in `pom.xml` and then "Maven" -> "Reload Project" from the project context menu in IntelliJ. – James_D Aug 11 '23 at 12:44
  • Thank you. Reloading the project worked, and now I am having no issues importing javafx web. The first few times I tried reloading the project, it did not work, but after trying multiple times it did. Not sure why that is, but I am just relieved it's fixed. – jari85 Aug 12 '23 at 15:50

0 Answers0