对于大学项目,我们需要实现一个服务器“注册器”,它通过 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 …Run Code Online (Sandbox Code Playgroud)