微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

JavaFX Modular项目问题

如何解决JavaFX Modular项目问题

我有gluon Mobile示例项目,并决定通过添加module-info.java类使其模块化,此后我一直收到许多程序包错误,例如:

error: package com.gluonhq.attach.util.impl is not visible
package com.gluonhq.attach.util.impl is declared in module com.gluonhq.attach.util,which does not export it
package com.sun.javafx is declared in module javafx.base,which does not export it to module Simple
package com.sun.javafx is not visible
package com.sun.javafx is declared in module javafx.base,which does not export it to module Simple
...

自从我在main()方法添加了以下代码段后,问题就开始了:

if(isWindows() || isMac() || isUnix()) {
            System.setProperty("javafx.platform","Desktop");
        }

        // define service for desktop
        StorageService storageService = new StorageService() {
            @Override
            public Optional<File> getPrivateStorage() {
                // user home app config location (linux: /home/[yourname]/.gluonmaps)
                return Optional.of(new File(System.getProperty("user.home")));
            }

            @Override
            public Optional<File> getPublicStorage(String subdirectory) {
                // this should work on desktop systems because home path is public
                return getPrivateStorage();
            }

            @Override
            public boolean isExternalStorageWritable() {
                //noinspection ConstantConditions
                return getPrivateStorage().get().canWrite();
            }

            @Override
            public boolean isExternalStorageReadable() {
                //noinspection ConstantConditions
                return getPrivateStorage().get().canRead();
            }
        };

        // define service factory for desktop
        ServiceFactory<StorageService> storageServiceFactory = new ServiceFactory<StorageService>() {

            @Override
            public Class<StorageService> getServiceType() {
                return StorageService.class;
            }

            @Override
            public Optional<StorageService> getInstance() {
                return Optional.of(storageService);
            }

        };
        // register service
        Services.registerServiceFactory(storageServiceFactory);

应该解决这个问题,并避免一些小事,这些事以后会成为大问题:

Sep 21,2020 2:09:35 PM com.gluonhq.attach.util.Platform <clinit>
INFO: javafx.platform is not defined. Desktop will be assumed by default.

请帮助!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。