I went through a lot of questions like this and this which were almost same as mine ,but couldn't help me in solving my problem. I am hence posting it for help.
I was trying to use the JDBC driver with PostgreSQL and followed this tutorial.
I tried the same Java program on Eclipse as well as trying to compile from the terminal. After putting the postgresql-9.4-1206-jdbc4.jar in the library folder in Eclipse, it compiles and runs perfectly in the IDE.
Now I have put my JDBCExample.java and postgresql-9.4-1206-jdbc4.jar in the same folder test.
But when I try in my terminal with this,
cd test
javac JDBCExample.java
java JDBCExample -cp postgresql-9.4-1206-jdbc4.jar
I get
-------- PostgreSQL JDBC Connection Testing ------------
Where is your PostgreSQL JDBC Driver? Include in your library path!
java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at JDBCExample.main(JDBCExample.java:14)
I also tried rewriting the second command as java JDBCExample -cp .:postgresql-9.4-1206-jdbc4.jar
but there is no change.
What is wrong here?