简体   繁体   中英

Javac cannot find jar for apache commons config

I'm trying to compile a very simple program in Java 1.6 on Ubuntu Jaunty, using Apache Commons Config jar. I keep getting the "package org.apache.commons.configuration does not exist" error, even though the jar is in the same directory. Any ideas?

  • Directory Listing
~/source/UpdateStockHistory$ ll
total 304
-rw-r--r-- 1 crosse crosse 298829 2009-06-07 17:36 commons-configuration-1.6.jar
-rw-r--r-- 1 crosse crosse    149 2009-06-07 17:16 UpdateStockHistory.config.xml
-rw-r--r-- 1 crosse crosse    531 2009-06-07 17:46 UpdateStockHistory.java
  • Java Version
~/source/UpdateStockHistory$ javac -version
javac 1.6.0_13
  • OS Version
~/source/UpdateStockHistory$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 9.04
Release:        9.04
Codename:       jaunty
  • Compiler Version
~/source/UpdateStockHistory$ javac UpdateStockHistory.java
UpdateStockHistory.java:2: package org.apache.commons.configuration does not exist
import org.apache.commons.configuration.*;
^
UpdateStockHistory.java:8: cannot find symbol
symbol  : class ConfigurationFactory
location: class com.crosse.tradingresearch.UpdateStockHistory
                        ConfigurationFactory factory = new ConfigurationFactory("UpdateStockHistory.config.xml");
                        ^
UpdateStockHistory.java:8: cannot find symbol
symbol  : class ConfigurationFactory
location: class com.crosse.tradingresearch.UpdateStockHistory
                        ConfigurationFactory factory = new ConfigurationFactory("UpdateStockHistory.config.xml");
                                                           ^
UpdateStockHistory.java:9: cannot find symbol
symbol  : class Configuration
location: class com.crosse.tradingresearch.UpdateStockHistory
                        Configuration config = factory.getConfiguration();
                        ^
4 errors

Hate to ask such a "do it for me" question, but I've run out of ideas.

尝试按如下方式将jar添加到您的类路径中:

javac UpdateStockHistory.java -cp commons-configuration-1.6.jar

Javac does not automatically search in the current directory for classes. You can tell it to using:

javac -cp . UpdateStockHistory.java

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