我有以下问题:我制作了一个 Java 应用程序,它在 Netbeans 的运行时中运行良好,但在构建后无法运行。这些库已正确包含,这是尝试从命令行运行它后发生的情况:
Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.xuggle.ferry.JNIMemoryManager.<init>(JNIMemoryManager.java:861)
at com.xuggle.ferry.JNIMemoryManager.<clinit>(JNIMemoryManager.java:860)
at com.xuggle.mediatool.MediaWriter.<clinit>(MediaWriter.java:119)
at com.xuggle.mediatool.ToolFactory.makeWriter(ToolFactory.java:149)
at app.RepaintImpl$1.run(RepaintImpl.java:63)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 6 more
NB 中的所有内容都设置为 JDK 7,我相信我的环境变量也很好:
CLASSPATH=C:\Program Files\Java\jre7\lib\*;C:\Program Files\Java\jre7\bin\*;
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_09
PATH=C:\Program Files\Java\jdk1.7.0_09\bin;...
这是构建日志,令我困扰的是 Netbeans 在 .jar 文件中创建空目录的事实:
ant -f "C:\\Users\\Wojtek\\Documents\\NetBeansProjects\\VNC Streamer" clean jar
init:
deps-clean:
Updating property file: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\built-clean.properties
Deleting directory C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build
clean:
init:
deps-jar:
Created dir: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build
Updating property file: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\built-jar.properties
Created dir: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\classes
Created dir: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\empty
Created dir: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\generated-sources\ap-source-output
Compiling 87 source files to C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\classes
Note: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\src\app\RepaintImpl.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Copying 1 file to C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\classes
Copied 25 empty directories to 24 empty directories under C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build\classes
compile:
Created dir: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\dist
Copying 1 file to C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\build
Copy libraries to C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\dist\lib.
Building jar: C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\dist\VNC_Streamer.jar
To run this application from the command line without Ant, try:
java -jar "C:\Users\Wojtek\Documents\NetBeansProjects\VNC Streamer\dist\VNC_Streamer.jar"
jar:
BUILD SUCCESSFUL (total time: 7 seconds)
任何帮助将不胜感激!