Exception in init method - JavaFX

后端 未结 2 965
囚心锁ツ
囚心锁ツ 2021-01-27 19:26

I get this exception after exporting into a .jar file with eclipse. IntelliJ says the same. But my program is working fine in eclipse.

Exception in thread \"main         


        
2条回答
  •  再見小時候
    2021-01-27 20:03

    The javafx.application.Application class is going to be found in a javafx library; in an IDE such as eclipse you generally configure a project to refer to those libraries it needs for compilation and execution. When you put your code into a jar and run it outside the IDE, you need to provide the library to the runtime a different way.

    A standard way to do this is to set a classpath which has references to both the application jar and to any libraries it needs; the DOS command to do this would look something like:

    set classpath=c:\myProjects\myApplication\myJar.jar;c:\java\libaries\javafx\jfxrt.jar
    

    and then java would have access to the classes in both those jar files

提交回复
热议问题