我希望答案会非常简单,但是由于 classnotfound 异常,我无法运行以下测试程序:
import java.net.URL;
import net.sourceforge.spnego.SpnegoHttpURLConnection;
public class HelloKeytab {
public static void main(final String[] args) throws Exception {
System.setProperty("java.security.krb5.conf", "krb5.conf");
System.setProperty("sun.security.krb5.debug", "true");
System.setProperty("java.security.auth.login.config", "login.conf");
SpnegoHttpURLConnection spnego = null;
try {
spnego = new SpnegoHttpURLConnection("spnego-client");
spnego.connect(new URL("http://as1.test.local/hello_spnego.jsp"));
System.out.println("HTTP Status Code: "
+ spnego.getResponseCode());
System.out.println("HTTP Status Message: "
+ spnego.getResponseMessage());
} finally {
if (null != spnego) {
spnego.disconnect();
}
}
}
}
我安装了JDK7并将JAVA_HOME
环境变量设置为管理员。在编译和运行时,我作为普通域用户在 Windows XP 机器上工作。
我和我spnego-r7.jar
在同一个目录中HelloKeytab.java
编译:
javac -cp .;spnego-r7.jar HelloKeytab.java
成功创建了类。
当我运行程序时:
java -cp .;spengo-r7.jar HelloKeytab
我收到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/spneg
o/SpnegoHttpURLConnection
at HelloKeytab.main(HelloKeytab.java:15)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.spnego.SpnegoHttpUR
LConnection
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
spnego-r7.jar
可以在这里找到:http : //sourceforge.net/projects/spnego/files/
我做错了什么,它没有找到我的班级?