找不到类,但是存在jar

时间:2013-04-02 14:06:24

标签: java xslt

in my program

package com.XSLTTransformation;

import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;

public class XSLTTransformation {
    public static void main(String[] args) {
        Collection<Employee> staff = new HashSet<Employee>();
        staff.add(new Employee("Derek", 35, 3000, 0.30));
        staff.add(new Employee("Elsa", 28, 1500, 0.15));
        staff.add(new Employee("Oleg", 32, 2300, 0.25));
        staff.add(new Employee("Neil", 34, 2500, 0.00));
        staff.add(new Employee("Maria", 34, 1700, 0.15));
        staff.add(new Employee("John", 35, 2800, 0.20));
        Map<String, Collection<Employee>> beans = new HashMap<String, Collection<Employee>>();
        beans.put("employee", staff);
        XLSTransformer transformer = new XLSTransformer();
        try {
            transformer.transformXLS("C:/Users/hussain.a/Desktop/malay/newprojectpocdetails/temp.xls", beans, "C:/Users/hussain.a/Desktop/malay/newprojectpocdetails/proovNYOutput.xls");
        } catch (ParsePropertyException e) 
        {
            e.printStackTrace();
        } catch (InvalidFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

我发现此错误

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/jexl2/parser/Node
    at net.sf.jxls.transformer.XLSTransformer.transformWorkbook(XLSTransformer.java:269)
    at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:221)
    at net.sf.jxls.transformer.XLSTransformer.transformXLS(XLSTransformer.java:201)
    at com.XSLTTransformation.XSLTTransformation.main(XSLTTransformation.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.jexl2.parser.Node
    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)

我已经放置了具有此类的jar,我无法识别真正的问题

1 个答案:

答案 0 :(得分:2)

commons-jexl.jar添加到 CLASSPATH ;

试试此链接:https://stackoverflow.com/a/8286795/1743852