• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javafx not working in Java 10

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code below compiles. I get method drop downs, etc., but when I try to run it in Java 10, I get symbol not found for all the JavaFX classes (Application, scene, etc.).

Supposedly, it won't be until JDK 11 this September (2018) when Oracle removes JavaFX from the standard JDK.

What do I need to do to get this simple code to run as in Java 8?

The example below is a simple example. I also downloaded an example from the Oracle site with the same errors.

Thanks,

- mike


 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

when I try to run it in Java 10


What do you mean by "run"?  
Are the errors from compiling
or from executing the compiled code?

I get symbol not found  


Can you copy the full text of the error messages and paste it here?
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:

when I try to run it in Java 10


What do you mean by "run"?  
Are the errors from compiling
or from executing the compiled code?

I get symbol not found  


Can you copy the full text of the error messages and paste it here?



I guess I should have said that the program "appears" to compile. That is, in Intellij, there are no errors in the editor. I can click an object and the "." and see available methods.

Yet, if I do try to re-compile the code, I get errors including these:

Error:(3, 26) java: package javafx.application does not exist
Error:(4, 20) java: package javafx.scene does not exist
Error:(5, 26) java: package javafx.scene.chart does not exist
Error:(6, 26) java: package javafx.scene.chart does not exist
Error:(7, 26) java: package javafx.scene.chart does not exist
Error:(8, 26) java: package javafx.scene.chart does not exist
Error:(9, 20) java: package javafx.stage does not exist
Error:(18, 38) java: cannot find symbol
 symbol: class Application
.
.
.

The confusing thing is that, as I noted above (see attachment), the method drop-downs are working so I'm baffled why the code won't compile.

Thanks in advance,

- mike
method-drop-downs-working.png
[Thumbnail for method-drop-downs-working.png]
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To fix this issue, I had to manually add the JavaFX JAR file from Java 8 to the project.

/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/ext/jfxrt.jar

It's strange, but there isn't even a "jre" folder in the JDK 10 install (see attachment).

Similarly, doing a "locate" shows no jfxrt.jar in the JDK 10 install elsewhere.

Don't get what happened.

Thanks,

-- mike
no-javafx-jar-file.png
[Thumbnail for no-javafx-jar-file.png]
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code compiled and ran without changes at my terminal:-The warning is about you using Data as a raw type. JavaFX has been included with the standard JDK download since (I think) Java8, four years ago. Please check whether there is an error with your IntelliJ settings. I shall add this discussion to the IntelliJ forum
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Your code compiled and ran without changes at my terminal:-The warning is about you using Data as a raw type. JavaFX has been included with the standard JDK download since (I think) Java8, four years ago. Please check whether there is an error with your IntelliJ settings. I shall add this discussion to the IntelliJ forum



Yes, I create a new project and it worked fine.

This was my goof.

In Intellij, under language levels, I didn't have the correct "language level".

It's fixed now.

FWIW, the problem happened as I was trying to find a library that was causing Intelilj (Java 10) to run out of Heap Space during running so I was doing lots of fiddling around.

Thanks very much for the replies!

- mike

Thanks,
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use ubuntu 16.04 and because I already had openJDK installed, this command have solved the problem. sudo apt-get install openjfx  Don't forget that JavaFX is part of OpenJDK.

 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sonai kale wrote:I use ubuntu 16.04 and because I already had openJDK installed, this command have solved the problem. sudo apt-get install openjfx  Don't forget that JavaFX is part of OpenJDK.



Hi,

As I noted my my latest reply above, the issue was fixed.

Thanks,

- mike
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

I have the same problem. Can you please walk me through to fix that? Thanks.
 
Ranch Hand
Posts: 270
15
Android Angular Framework Spring AngularJS Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, All.

While I am actually still struggling with a related issue (that is, I am no expert), I can tell you something pivotal to your understanding of this problem.

Java7 and Java8 included JavaFX in their JVM.  As of Java9, that was no longer the case.  Java9 through Java12 (+ assume) requires you to get JavaFX as a module and use that module.  If you are using Maven, you can get past this by including dependencies.  I think these should work.


However, the swing dependency may not be needed, and there are other dependencies to do with JavaFX that you may need, such as javafx-fxml and javafx-media.

Please refer also to https://openjfx.io/openjfx-docs/ for further info.

I hope this helps someone.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point.  Here is a piece of my pom file that includes the module for FXML files:
And there are other, too.
 
reply
    Bookmark Topic Watch Topic
  • New Topic