我在尝试创建javafx scala项目时被阻止。我在intellij idea 13(ast项目)中创建了一个scala项目,然后我手动添加了scalafx的jar(“scalafx_2.10-8.0.0-M1.1”)。 jar”)并复制了这个小程序:
object World extends JFXApp {
stage = new JFXApp.PrimaryStage {
title = "Hello World"
width = 600
height = 450
scene = new Scene {
fill = Color.LIGHTGREEN
content = Set(new Rectangle {
x = 25
y = 40
width = 100
height = 100
//fill <== when(hover) then Color.GREEN otherwise Color.RED
})
}
}
}
但不幸的是我收到此错误消息:
Exception in Application start method Exception in thread "main" java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:399) at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47) at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.NoClassDefFoundError: javafx/scene/shape/CullFace at scalafx.Includes$.(Includes.scala:55)
问题似乎与 javafx 有关,我忽略了它,因为它通常包含 java7... 你能告诉我我做错了什么吗?
最佳答案
scalafx_2.10-8.0.0
适用于 Java 8。如果您需要使用 Java 7,请获取 scalafx_2.10-1.0.0
。
在 Java 7 中,默认情况下 JavaFX 不在类路径中,因此您可能需要添加它,尽管 IntelliJ 添加了它。
关于scalafx + intellij : NoClassDefFoundError: javafx/scene/shape/CullFace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20505659/