Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

javafx not working in Java 10  RSS feed

 
Bartender
Posts: 1661
17
  • Mark post as helpful
  • send pies
  • 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: 3353
33
  • Mark post as helpful
  • send pies
  • 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: 1661
17
  • Mark post as helpful
  • send pies
  • 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: 1661
17
  • Mark post as helpful
  • send pies
  • 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: 64182
215
  • Mark post as helpful
  • send pies
  • 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: 1661
17
  • Mark post as helpful
  • send pies
  • 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
  • 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: 1661
17
  • Mark post as helpful
  • send pies
  • 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
  • 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: 259
15
Android Angular Framework AngularJS Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 5931
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
A berm makes a great wind break. And Iwe all like to break wind once in a while. Like this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!