2

I Installed postgresql and its driver which is "postgresql-9.3-1102.jdbc41.jar".

And my directory seems like :

> SQL
>     myJDBC.java
>     postgresql-9.3-1102.jdbc41.jar

I have tried :

javac -cp postgresql-9.3-1102.jdbc41.jar myJDBC.java
java -cp postgresql-9.3-1102.jdbc41.jar myJDBC

It compiles fine but when I try to execute it, I get error which is :

Error: Could not find or load main class myJDBC

What am I missing ?

0

1 Answer 1

2

The current directory needs to be added to the runtime classpath

java -cp .:postgresql-9.3-1102.jdbc41.jar myJDBC
         ^
Sign up to request clarification or add additional context in comments.

11 Comments

When I do that I get : java.lang.ClassNotFoundException: org.postgreql.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)
There ought to be a letter 's' in org.postgreql.Driver, check your code
Sorry, my edit and comment had become obsolete in light of your ClassNotFoundException.
@okiharaherbst I'm truly sorry I'm kind of newbie I didn't get it what do you mean, The Jar file and myJDBC in same directory already ? how can use fully qualified package name ?
@okiharaherbst oh my god, I get it now what a mistake,I'm grateful,thank you for your attention...
|

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.