views:

646

answers:

2

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.

+3  A: 

Try adding the jar to your classpath as so:

javac UpdateStockHistory.java -cp commons-configuration-1.6.jar
Adam Rosenfield
Thank you very much. I didn't realize I needed to add individual jars to my classpath.
C. Ross
+1  A: 

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

javac -cp . UpdateStockHistory.java
AgileJon