在MANIFEST.MF中加入Class-Path属性,把log4j等jar包的相对本jar文件的路径以及文件全名作为属性值即可。 一般的做法是将这些jar文件与你的程序jar包放在同一个文件夹下,这样只写入文件名就行了。以下摘自:http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.htmlThe value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path.
我编译的时候报错Exception in thread "main" java.lang.NoClassDefFoundError: jiancha/jar
又报了这么错Exception in thread "main" java.io.IOException: invalid manifest format
Exception in thread "main" java.io.IOException: invalid manifest format at java.util.jar.Manifest.read(Manifest.java:193) at java.util.jar.Manifest.<init>(Manifest.java:52) at java.util.jar.JarFile.getManifest(JarFile.java:158)这个问题一直出现阿
一般的做法是将这些jar文件与你的程序jar包放在同一个文件夹下,这样只写入文件名就行了。以下摘自:http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.htmlThe value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path.
Manifest-Version: 1.0
Created-By: 1.4.0_03 (Sun Microsystems Inc.)
Class-Path: ./log4j.jar写出来可要另加分哦!:)
at java.util.jar.Manifest.read(Manifest.java:193)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at java.util.jar.JarFile.getManifest(JarFile.java:158)这个问题一直出现阿
Manifest-Version: 1.0Main-Class: com.gwssi.sa.business.GxMessage
Class-Path: ./log4j-1.2.8.jar
Class-Path: d:/j2sdk1.4.1_01/jre/lib
Manifest-Version: 1.0
Main-Class: com.gwssi.sa.business.GxMessage
Class-Path: ./log4j-1.2.8.jar然后我的程序文件x.jar和log4j-1.2.8.jar放在同一目录下,用java -jar x.jar命令执行
报错
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at com.gwssi.sa.business.BusinessData.<clinit>(BusinessData.java:21)
at com.gwssi.sa.business.Gx_SendPatrol.run(Gx_SendPatrol.java:32)
at java.lang.Thread.run(Thread.java:534)很郁闷!
Class-Path: log4j-1.2.8.jar