来源fie - > location c:/ program files / java / jdk1.6.0_07 / bin
import java.io.File;
import java.io.IOException;
import jxl.*;
public class Geeta {
private String inputFile;
public void setInputFile(String inputFile) {
this.inputFile = inputFile;
}
public void read() throws Exception {
File inputWorkbook = new File(inputFile);
Workbook w;
w = Workbook.getWorkbook(inputWorkbook);
// Get the first sheet
Sheet sheet = w.getSheet(0);
// Loop over first 10 column and lines
Cell a1 = sheet.getCell(0,0);
String stringa1 = a1.getContents();
System.out.println(stringa1);
}
public static void main(String[] args) throws Exception {
Geeta test = new Geeta();
test.setInputFile("c:/Progra~1/Java/jdk1.6.0_07/bin/jxlrwtest.xls");
test.read();
}
}
编译为 javac -classpath jxl.jar Geeta.java
当我尝试执行它时说.. NoClassDefFoundError
java -jar jxl.jar Geeta
C:\ Program Files \ Java \ jdk1.6.0_07 \ bin> java -jar jxl.jar Geeta 线程“main”中的异常java.lang.NoClassDefFoundError:Geeta 引起:java.lang.ClassNotFoundException:Geeta 在java.net.URLClassLoader $ 1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) 在java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) 在java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
PLZ。建议...
答案 0 :(得分:1)
我在执行jxl时遇到错误,它是关于CLASSPATH
的这对我有用:
在环境变量中更改或设置CLASSPATH:
打开一个新的CMD窗口并照常编译。
答案 1 :(得分:0)
您的运行命令应如下所示:
java -classpath jxl.jar;. Geeta