Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

What is this error?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have written a Java swing applction that has on a panel, with a JFrame, an array of JTextFields. The user is allowed to enter values into any of the fields.
There are two buttons beneath the array of fields, one that is activated once all the fields are complete, and another that simply cancels the application.

Everytime it runs, I get this error showing "Exception in thread "AWT-EventQueue-1" java.lang.NoClassDefFoundError: javafx/scene/input/KeyCombination"

What does this mean?

Regards
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it means you have mixed Swing and JavaFX technologies.  If you are building a Swing application, don't use JavaFX classes.
 
Marshal
Posts: 69882
278
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is actually possible to mix Swing and FX classes, because there are FX components which can act as containers for Swing components, but I don't know how to do it myself.
What version of Java® are you using? Have you looked at its documentation to see whether it supports FX out of the box? I think Java8 does, and I think Java5/6/7/11 don't, but I am not certain. If you are using one of the versions that don't support FX, you would probably have to download an FX .jar file and put that in your application's CLASSPATH, which is probably best done with the -cp option for the java and javac tools. Look through this Java™ Tutorials section, but resist the temptation to set a permanent CLASSPATH.

The particular exception you are suffering suggests maybe the KeyCombination class was available via a CLASSPATH when you compiled the application, but is not similarly available to the current runtime. Did you compile and execute the code with different versions of Java®?
 
Jeremy Watts
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both for the replies. To be honest, I had no idea I was using JavaFX anywhere. What is true is that the same program runs on a Windows machine without the error (likely using an earlier version of Java), to the version on Linux which is producing the error. The code isn't that long, if I were to post it could you point out where I am using JavaFX please?

Thanks
 
Campbell Ritchie
Marshal
Posts: 69882
278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeremy Watts wrote:. . . if I were to post it could you point out where I am using JavaFX please?

Thanks

Most probably, yes.

Please check which version of Java® you are using; if your Windows® box used Java8 and you are now on Java11/OpenJDK11, that might cause that particular problem.
 
Jeremy Watts
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, the Linux version is "10.0.2", & the Windows one would have been a much earlier version - likely 4years earlier
 
Jeremy Watts
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Marshal
Posts: 69882
278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can see all sorts of things about that code, but not where you are using any FX classes. Are you sure that is the code producing that error message? I can't remember whether FX was still included in the standard Java10 download.
 
Rancher
Posts: 4623
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought it was taken out in 9 when modules came in.

What's the full stack trace for that exception?
That'll tell you what class appears to be using FX.
 
Jeremy Watts
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell, Dave, Thanks both for helping.

The IDE that I am using is called BlueJ, and I am running that on Linux Mint O/S. So, to recap, I run the program, and it does what I want it to do pretty much, displaying a  JFrame with two buttons and an array of JTextFields. But, at the same time the BlueJ terminal window appears as i the graphic that I have included. The text portion on the lower half of the screen assumedly contains the stack trace? Ignore the top half, as this just contains some System.out.print 'doodlings'.

To me this error seems bizarre, as I say I had no idea I was using any JavaFX, and also the same program when run on my windows machine produces no error.

Jeremy
Screenshot-from-2019-01-23-09-13-37.png
[Thumbnail for Screenshot-from-2019-01-23-09-13-37.png]
 
Saloon Keeper
Posts: 12161
258
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of BlueJ are you using? I can't find a mention of KeyCombination in the source code of the latest version of BlueJ. Maybe an older version of BlueJ mistakenly assumed that JavaFX was being used.

If you're using an older version than BlueJ 4.1.4, try updating.
 
Dave Tolls
Rancher
Posts: 4623
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep.
the top line of that stack trace tells you what bit of code threw the exception.
In this case it was in the bluej.utility.Utility class, so it's BlueJ that had an issue and not your code.

As Stephan says, it's likely you have an old version of it on your Linux box.
 
The knights of nee want a shrubbery. And a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic