java.lang.NoClassDefFoundError:BoothServer

java.lang.NoClassDefFoundError:BoothServer,java,Java,我将按照本教程创建简单的SSLServer和客户端套接字。我已经使用keytool创建了证书,但是执行上面教程中的这一行时遇到问题 java-Djavax.net.ssl.keyStore=mySrvKeystore-Djavax.net.ssl.keystrepassword=123456 EchoServer 我应该把证书放在哪里?在项目目录中? 如何传递上述参数 我这样做,并得到错误 C:\Users\abc\workspace\VirtualElectionBoothServer\bin

我将按照本教程创建简单的SSLServer和客户端套接字。我已经使用keytool创建了证书,但是执行上面教程中的这一行时遇到问题

java-Djavax.net.ssl.keyStore=mySrvKeystore-Djavax.net.ssl.keystrepassword=123456 EchoServer

我应该把证书放在哪里?在项目目录中? 如何传递上述参数

我这样做,并得到错误

C:\Users\abc\workspace\VirtualElectionBoothServer\bin>java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 BoothServer
    Exception in thread "main" java.lang.NoClassDefFoundError: BoothServer
Caused by: java.lang.ClassNotFoundException: BoothServer
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: BoothServer.  Program will exit.
编辑: 我的问题是,我从不从命令行运行项目,所以我不知道如何从命令行运行该行

C:\Users\abc\workspace\VirtualElectionBoothServer\bin>java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 BoothServer

我应该从哪个目录运行它?我有不止一个.java文件。跑哪一个?一个有main?

看起来您不知道如何从命令行运行Java应用程序

我假设您的BoothServer类不在包中。如果是,请使用其全名,例如.package.name.BoothServer

我还假设您已经在eclipse中编译了这个类,并且生成的类文件位于bin目录中。如果您使用的是软件包,则应将文件放在bin\the\package\name\BoothServer.class下。当然,如果是这种情况,请用实际的包名替换目录名

javax.net.ssl.SSLException:没有可用的证书或密钥 对应于已启用的SSL密码套件

这是在其他原因中找不到密钥库时发生的典型错误

确保与-Djavax.net.ssl.keyStore=一起使用的路径指向您生成的实际密钥库。例如,-Djavax.net.ssl.keyStore=..\mySrvKeyStore,如果您的文件位于C:\Users\abc\workspace\VirtualElectionBoothServer下


我还怀疑Eclipse可能会在每次重新编译时清除bin的内容,因此bin不一定是保存密钥库文件的好地方。

标题中有javax.net.ssl.SSLException,实际问题中有ClassNotFoundException。是哪一个?你的档案在哪里?你肯定需要首先修复ClassNotFoundException。我已经编辑了这个问题,告诉你我到底面临什么。非常感谢你。它奏效了,我从你那里学到了很多。再次感谢你。