JavaFX doesn't work on Heroku (NoClassDefFoundError)

北城余情 提交于 2020-01-05 04:04:10

问题


I have some JavaFX includes in my tomcat server application, like a javafx pair, and some properties, but it seems that they cause an error on heroku:

java.lang.NoClassDefFoundError: javafx/util/Pair

I see that it installs openJDK 1.8 when deploying the war, so how come it doesn't find JavaFX?


回答1:


The JDK on Heroku is headless, and does not include the javafx JAR. You can include it manually by adding something like this to your pom.xml:

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>javafx</artifactId>
    <version>2016.10.0</version>
</dependency>

That distribution is provided by RedHat. There are other distributions on Maven Central.




回答2:


Another solution is adding this buildpack to your app:

 $ heroku buildpacks:add -i 1 https://github.com/jkutner/heroku-buildpack-javafx


来源:https://stackoverflow.com/questions/40348237/javafx-doesnt-work-on-heroku-noclassdeffounderror

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