IM已經設置log4j12-API beta2.jar構建路徑,但它給人的 以下錯誤,請幫我解決這個問題
我的代碼如下 的java文件:ClassNotFoundException的2.0
package com.sst.log4j;
class Product {
private int productId;
private String productName;
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public Product(int productId, String productName) {
super();
this.productId = productId;
this.productName = productName;
}
}
和我的主要()文件:
package com.sst.log4j;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
public class ProductMain {
/**
* @param args
*/
static Logger log=LogManager.getLogger(Product.class.getName());
public static void main(String[] args) {
// TODO Auto-generated method stub
Product p1=new Product(1,"garlands");
System.out.println(p1.getProductName());
log.error(p1.getProductName());
}
}
它提供了以下異常:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/
log4j/LogManager
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.apache.log4j.LogManager.getLogger(LogManager.java:38)
at com.sst.log4j.ProductMain.main(ProductMain.java:14)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 14 more
我安裝了這兩個罐仍然顯示相同的例外 – venkyMCA