我想检查我的JavaFX应用程序的场景图。
我已经下载了ScenicView.jar,并将其放在.fxml和.java文件旁边的项目文件夹中(我正在使用Eclipse)。

在VM参数中,我有-javaagent:C:\ path \ to \ bin \ application \ scenicview.jar

每当我运行Main类时,都会出现此错误:

Platform running
Launching ScenicView v9.0.0
java.lang.IllegalStateException: Location is not set.
    at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2459)
    at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2435)
    at org.scenicview.view.tabs.CSSFXTab.createTabContent(CSSFXTab.java:62)
    at org.scenicview.view.tabs.CSSFXTab.<init>(CSSFXTab.java:54)
    at org.scenicview.view.ScenicViewGui.buildUI(ScenicViewGui.java:300)
    at org.scenicview.view.ScenicViewGui.<init>(ScenicViewGui.java:214)
    at org.scenicview.ScenicView.start(ScenicView.java:182)
    at org.scenicview.ScenicView.lambda$premain$0(ScenicView.java:124)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
    at java.base/java.lang.Thread.run(Thread.java:844)
Startup done
Creating server
Server done
Number of running Java applications found: 4
Obtaining properties for Java application with PID:8208
Obtaining properties for Java application with PID:12132
Error while obtaining properties for JVM:sun.tools.attach.AttachProviderImpl@3a5a5f11: 2572 application.GUI
java.io.IOException: Can not attach to current VM
    at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.<init>(HotSpotVirtualMachine.java:75)
    at jdk.attach/sun.tools.attach.VirtualMachineImpl.<init>(VirtualMachineImpl.java:48)
    at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:69)
    at jdk.attach/com.sun.tools.attach.spi.AttachProvider.attachVirtualMachine(AttachProvider.java:193)
    at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:249)
    at org.fxconnector.remote.RemoteConnectorImpl.getRunningJavaFXApplications(RemoteConnectorImpl.java:368)
    at org.fxconnector.remote.RemoteConnectorImpl.connect(RemoteConnectorImpl.java:251)
    at org.scenicview.model.update.RemoteVMsUpdateStrategy.getActiveApps(RemoteVMsUpdateStrategy.java:57)
    at org.scenicview.model.update.RemoteVMsUpdateStrategy.work(RemoteVMsUpdateStrategy.java:77)
    at org.fxconnector.helper.WorkerThread.run(WorkerThread.java:43)
Obtaining properties for Java application with PID:8636
1 JavaFX applications found
Loading agent from: C:\Users\Ed\workspace\ModelFX\bin\application\scenicview.jar
Loading agent for:sun.tools.attach.AttachProviderImpl@3a5a5f11: 12132 ID:12132 on port:7566 took:107ms using agent defined in C:\Users\Ed\workspace\ModelFX\bin\application\scenicview.jar
Remote agent started on port:7566
RemoteApp connected on:7558 stageID:StageID [appID=12132, stageID=1986442457, name=null]
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at org.scenicview.view.tabs.CSSFXTab.setActiveStage(CSSFXTab.java:112)
    at org.scenicview.view.ScenicViewGui.setActiveStage(ScenicViewGui.java:736)
    at org.scenicview.model.update.AppsRepository.lambda$appAdded$3(AppsRepository.java:97)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
    at java.base/java.lang.Thread.run(Thread.java:844)


我猜它无法读取代码中正在加载的FXML文件?在各种控制器类中,我有类似以下内容:

        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(getClass().getResource("file.fxml"));
        loader.setController(this);
        Parent root = loader.load();


我真的没有得到这个,它没有付出太多!

编辑:我应该提到,没有VM参数程序将按预期运行。仅当我尝试加载Scenic View时才会出现该错误。

最佳答案

我刚才有同样的问题。
退回到Scenic View v8.7.0。将其添加为库。
在您的代码中添加ScenicView.show(scene);,它将启动。
请注意,您将需要安装当前的项目JRE和JDK8。

10-04 18:08