我构建了一个非常胖的 JavaFX 应用程序(JAR 大约 128 MB)并且通过 IntelliJ 运行没有问题。但是当我从终端运行它时,我的 3D 模型加载器(Fxyz3d 库)启动了这个异常。
Exception in thread "JavaFX Application Thread" java.nio.file.FileSystemNotFoundException
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:172)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:158)
at java.base/java.nio.file.Path.of(Path.java:208)
at java.base/java.nio.file.Paths.get(Paths.java:98)
at org.fxyz3d.importers.obj.ObjImporter.read(ObjImporter.java:115)
at org.fxyz3d.importers.obj.ObjImporter.loadAsPoly(ObjImporter.java:102)
at org.fxyz3d.importers.Importer3D.loadIncludingAnimation(Importer3D.java:160)
at org.fxyz3d.importers.Importer3D.loadAsPoly(Importer3D.java:80)
at it.polimi.ingsw.PSP50.View.GUI.GuiView.lambda$startingGame$1(GuiView.java:201)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
Run Code Online (Sandbox Code Playgroud)
这仅针对 Fxyz3d 库中的 3D 对象加载器抛出,而不针对我的其他普通 FXML 加载器。我使用相同的方式从我的 src/main/resources 文件夹中获取文件,即 getClass().getResource。那么这真的是路径问题吗?还是图书馆的问题?在 IntelliJ 中完全没有问题,一切正常。这是代码中不起作用的部分:
Model3D boardModel = Importer3D.loadAsPoly(getClass().getResource("/boardcliff2.obj"));
Run Code Online (Sandbox Code Playgroud)
如果有人以前遇到过这样的事情并且知道发生了什么,那么将非常感谢您的帮助
我正在为游戏开发 GUI,我想在 JavaFX 中混合 3D SubScene 和 2D Pane。我有一个名为 root3D 的组,其中包含已正确设置的所有 3d 对象,然后我使用通过 JavaFX Scene Builder 设置的 FXML 文件创建一个窗格。但什么也没有显示,我只能看到我的 3D 对象。
PerspectiveCamera camera = new PerspectiveCamera(true);
camera.setTranslateZ(-30);
Group root3D = new Group(model1,model2,model3); //various 3d models I imported
SubScene subScene = new SubScene(root3D, 1280, 700, true,SceneAntialiasing.BALANCED);
subScene.setCamera(camera);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/file.fxml"));
AnchorPane pane = loader.load();
pane.getChildren().add(subScene);
Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
Run Code Online (Sandbox Code Playgroud)
FXML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.StackPane?>
<?import …Run Code Online (Sandbox Code Playgroud)