1

In my ~/.bashrc I export my java CLASSPATH the following way:

CLASSPATH=$CLASSPATH:/home/user/java/libs/apache-ant-1.9.0/lib/*:/home/user/java/MyProject/libs/*

The folder "/home/user/java/MyProject/libs/" contains the following jars:

colt.jar    mysql-connector-java-5.1.22-bin.jar
concurrent.jar  postgresql-8.4-703.jdbc4.jar

When I try to compile a class of my project that imports parts the colt.jar, I get an error message:

/src$ javac visualization/VisualizeCorrelationMatrix.java 
visualization/VisualizeCorrelationMatrix.java:16: cannot access cern.colt.matrix.impl.SparseDoubleMatrix2D
class file for cern.colt.matrix.impl.SparseDoubleMatrix2D not found
        int N = cm.columns();
                  ^

But when compling it the followin way it works without errors:

/src$ javac -cp ".:/home/user/java/MyProject/libs/*" visualization/VisualizeCorrelationMatrix.java

I checked that the paths in the CLASSPATH variable and the manuel optino -cp are 100% identical. Also an echo $CLASSPATH returns the correct path.

Why do I still get this error?

1 Answer 1

6

You need to export the new classpath variable in your bashrc line:

export CLASSPATH=$CLASSPATH:/home/user/java/libs/apache-ant-1.9.0/lib/*:/home/user/java/MyProject/libs/*

Also if the shell you are compiling the java in was created before you changed your bashrc file you'll want to reread the bashrc file using source ~/.bashrc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.