简体   繁体   中英

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; I've add it's jar file location to the classpath environment variable. When I try to compile the code via the command line I get numerous errors including: package org.apache.commons.io does not exist

You are missing the jar that contains this package (in your case apache-commons.jar) on your classpath.

Try to export the packaged jar file with the dependend jars included. That should work.

Complile like this:

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!

In that case just drop common-io-xx.jar under your ...\\Java\\jdk1\\jre\\lib\\ext

Ofcourse that will work :) Only wasted a few hours to get to that conclusion!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM