Hi,
I have put my
java source file inside /usr/java/jdk1.6.0_04/bin and compiled the program using javac Voice1.java.It gets compiled.
But when i tried to run the program using java Voice1,it displays the following error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at Voice1.getMySqlConnection(Voice1.java:24)
at Voice1.run(Voice1.java:79)
at Voice1.main(Voice1.java:305)
Then i have added mysql connector.jar in the path /usr/java/jdk1.6.0_04/bin and then i tried to run the class as follows:
java -cp mysql-connector-java-3.0.17-ga-bin.jar Voice1
Now i am getting the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: Voice1
Caused by: java.lang.ClassNotFoundException: Voice1
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
what is the problem here? Any classpath issue?Please help me to solve this.
Thanks.