如何处理“java:没有枚举常量 javax.lang.model.element.Modifier.SEALED”构建错误?

问题描述 投票:0回答:2

对于大学项目,我们需要实现一个服务器“注册器”,它通过 SSL RMI 连接与客户端“barowner”进行通信。构建客户端时,出现错误 java: No enum Constant javax.lang.model.element.Modifier.SEALED 构建错误。服务器构建没有任何问题。

BarownerMain.java

package com.example.BarOwner;

import com.example.registrar.RegistrarInterface;

import javax.rmi.ssl.SslRMIClientSocketFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class BarOwnerMain {
    public static void main(String[] args) throws RemoteException {

        String pass = "password";
        System.setProperty("javax.net.ssl.debug", "all");
        System.setProperty("javax.net.ssl.keyStore", System.getProperty("user.dir") + "/keys/raynaud.jks");
        System.setProperty("javax.net.ssl.keyStorePassword", pass);
        System.setProperty("javax.net.ssl.trustStore", System.getProperty("user.dir") + "/keys/raynaud.jks");
        System.setProperty("javax.net.ssl.trustStorePassword", pass);

        Registry registrarRegistry;
        RegistrarInterface registrarInterface;
        try {
             registrarRegistry = LocateRegistry.getRegistry(
                    InetAddress.getLocalHost().getHostName(), 1112,
                    new RMISSLClientSocketFactory());
            registrarInterface = (RegistrarInterface) registrarRegistry.lookup("RegistrarService");
            BarOwnerMenu.showMenu(registrarInterface);
        } catch (RemoteException | NotBoundException e) {
            throw new RuntimeException(e);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

    }
}

我已经尝试按照 JDK-8244367 中的描述编辑 javax.lang.module,但 IntelliJ 不允许我这样做。任何帮助将不胜感激!

java ssl rmi
2个回答
1
投票

尝试将SDK版本更改为15,然后返回到更新后的版本。 您可以在“项目结构”中更改 DSK 版本,快捷方式:

ctrl+alt+shift+S

确保单击“应用”按钮。

它帮助我解决了同样的问题。


0
投票

我通过降低语言水平解决了同一个项目。 从jdk 17+开始,引入了密封类型

1) 转到文件>>项目结构。
2)单击语言级别下拉列表并将其设置为16

关闭并重建您的应用程序。现在应该可以工作了。

© www.soinside.com 2019 - 2024. All rights reserved.