user3254491 user3254491 - 5 months ago 51
Apache Configuration Question

How to set CLASSPATH for Apache Derby DB

I tried to set the Path environment variable of entering the path: "C: \ Program Files \ Java \ jdk1.8.0_101 \ db \ lib" (.jar file path) but nothing ...
I created a new variable called CLASSPATH by entering the same path and still nothing ...
How can I link this path to the compiler?

compile error


You can't set CLASSPATH to the directory where the jar files are stored; you have to specify the actual jar file by its full name.

This is a difference between a directory full of java .class files, versus a directory full of java .jar files.

So set your CLASSPATH to:

c:\Program Files\Java\jdk1.8.0_101\db\lib\derby.jar;c:\Program Files\Java\jdk1.8.0_101\db\lib\derbyclient.jar

In your particular case, since the only class you're trying to reference is ClientDriver, which is in derbyclient.jar, you could just set CLASSPATH to c:\Program Files\Java\jdk1.8.0_101\db\lib\derbyclient.jar and leave derby.jar out, but at some point in the future you might want to reference other Derby classes, such as EmbeddedDriver, so you might as well put both derby.jar and derbyclient.jar into your CLASSPATH now.