Are you sure that
- Your JDK has one of the JAR files (see below) that contain the KeyPairGenerator class?
I documented what JAR files contain this class below.
- The CLASSPATH is set to include the path to one of the above JAR files?
- Your JAVA_HOME is set ?
According to findJAR.com, the KeyPairGenerator class is contained in these JAR files:
rt.jar
org.osgi.foundation-1.0.0.jar
org.osgi.foundation-1.2.0.jar
I searched for rt.jar:
- The
rt.jar file is in my ANT lib directory.
- The
rt.jar file is also in the jre/lib subdirectory of my JDK directory.
If you don't have a containing JAR file anywhere, then try adding the ANT lib directory to your CLASSPATH.
This test ANT project can be used to verify SSH is working:
<?xml version="1.0" encoding="windows-1252" ?>
<project name="ServerSSH" default="dist" basedir=".">
<target name="dist">
<echo message="TEST BEGINNING"></echo>
<sshexec host="svr1"
username="user1"
description="Test connection"
keyfile="c:/.ssh/id_rsa"
trust="true"
command="echo CONNECTION SUCCESS FOR SERVER SVR1"
failonerror="true"/>
<echo message="TEST END"></echo>
</target>
</project>
This test can be invoked as follows:
set JAVA_HOME=c:\progra~1\Java\jdk1.7.0_21
set ANT_HOME=C:\ant
set ANTLIB=c:\ant\lib
set PATH=%ANT_HOME%\bin;%ANT_HOME%\lib;
ant -d -lib %ANTLIB% dist -f SSHTEST.xml
By running a test, you can verify whether SSH for JAVA will work outside of the project.