Problems running JavaFX application on Java 1.7u80

安稳与你 提交于 2019-12-09 19:51:56

问题


I am using Netbeans 8.02 on the MAC and am creating a simple JavaFX application from the New Project Wizard.

When I set the platform to Java 1.8 it works just fine, but when I try to run it on Java 1.7u80 I get "java.lang.NoClassDefFoundError: javafx/application/Application". Behavior is the same when running from the IDE or from the command line.

Everything compiles just fine with either platform, so it does look like JavaFX is on the classpath for both platforms I have installed.

My target application will have to run on 1.7, so I cannot simply go with 1.8 and call it a day.


回答1:


If you want to run JavaFx application on Java 1.7, you need to add jfxrt.jar into your classpath manually. In Java 1.8 jfxrt.jar is in the classpath by default. So that's why you got this problem while running it on 1.7.

You should be able to add it via your IDE. You can also use some third party tools like JavaFx Maven Plugin




回答2:


It turns out I ran into this known bug in NetBeans IDE.

https://netbeans.org/bugzilla/show_bug.cgi?id=239388

It sounds like the path settings is causing the ide to use the Ant script which builds for platform V 1.8 by accident.

I changed the platform for Netbeans itself to be JDK 1.7 and now everything builds fine for 1.7 and runs the JavaFX app 100% using JDK 1.7u80.



来源:https://stackoverflow.com/questions/30995989/problems-running-javafx-application-on-java-1-7u80

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!