[英]I have import org.apache.commons.io.FileUtils; in my code and it works on eclipse but not in command line
I'm using an Apache package; 我正在使用Apache包; I've add it's jar file location to the classpath environment variable.
我将它的jar文件位置添加到classpath环境变量中。 When I try to compile the code via the command line I get numerous errors including: package org.apache.commons.io does not exist
当我尝试通过命令行编译代码时,我收到很多错误,包括:package org.apache.commons.io不存在
You are missing the jar that contains this package (in your case apache-commons.jar) on your classpath. 您在类路径上缺少包含此包的jar(在您的情况下为apache-commons.jar)。
Try to export the packaged jar file with the dependend jars included. 尝试使用包含的dependend jar导出打包的jar文件。 That should work.
这应该工作。
Complile like this: 像这样的Complile:
javac -cp .:common-io-xx.jar YourProgram.java
Run it like this: 像这样运行:
java -cp .:common-io-xx.jar YourProgram
Actually the above option will not work sometimes. 实际上,上述选项有时不起作用。
At run time it might not find the class YourProgram :( Strange but true! 在运行时它可能找不到类YourProgram :(奇怪但真实!
In that case just drop common-io-xx.jar under your ...\\Java\\jdk1\\jre\\lib\\ext 在这种情况下,只需将common-io-xx.jar放在您的... \\ Java \\ jdk1 \\ jre \\ lib \\ ext下
Ofcourse that will work :) Only wasted a few hours to get to that conclusion! 当然会有效:)只浪费了几个小时才得出结论!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.