I’m following this tutorial http://stilius.net/java/java_ssl.php to create simple SSLServer and client sockets. I’ve created the certificate using keytool but I’ve a problem executing this line from the above tutorial,
“java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 EchoServer”.
Where should I put the certificate? in project directory?
how can I pass the parameters mentioned above?
I’m doing this and getting error;
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.
Edit:
my problem is that I never run a project from command line so I don’t know how to run this line from command line;
C:\Users\abc\workspace\VirtualElectionBoothServer\bin>java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 BoothServer
From which directory should i run it? I’ve more than one .java files. which one to run? one having main()?
It looks like you don’t know how to run a Java application from the command line.
I’ll just assume that your
BoothServerclass isn’t in a package. If it is, use its full name (e.g.the.package.name.BoothServer).I’ll also assume that you’ve compiled this within eclipse and that the resulting class file is in the
bindirectory. (If you are using packages, you should have your file underbin\the\package\name\BoothServer.class. Replace the directory names with the actual package names if this is the case, of course.)This is the typical error that happens when the keystore can’t be found (amongst other reasons).
Make sure the path you’re using with
-Djavax.net.ssl.keyStore=points to the actual keystore you’ve generated. For example,-Djavax.net.ssl.keyStore=..\mySrvKeyStoreif your file is underC:\Users\abc\workspace\VirtualElectionBoothServer.I also suspect that Eclipse might clear the content of
binevery time it recompiles (not sure), sobinwould not necessarily be a good place to keep that keystore file.