I have created some 4 to 5 Java files. They work well when I run using Netbeans or Eclipse, but when I try to run using command prompt I get some errors.
- I have put all my files in
jdk/binfolder. - I am using MySQL connector jar file – I have put that file in
jdk/binfolder - I have set my class path to
jdk/binfolder
But I get errors like:
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 Dbconnection.Dbconnect(Dbconnection.java:29)
at fileoperation.parsefiles(fileoperation.java:63)
at fileoperation.main(fileoperation.java:127)
Will anybody tell – where is the problem?
First of all try running java and javac from command propmt, if they run properly its fine.
than Try this:
cpstands forclasspathYou can also add multiple jar files after -cp.
if they don’t run i mean
java or javac not founderror comes up than addjava.exeandjavac.exeto your windowsenvironment variableAdd
C:\jdk1.6.0_23\binwhich contains java.exe and javac.exe to your environment variable.