Question: 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/bin` folder.
* I am using MySQL connector jar file - I have put that file in `jdk/bin` folder
* I have set my class path to `jdk/bin` folder

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?

Answer: 
Here is what you have to do.

1.It is not a good idea to place source files in the jdk bin directory.so undo that.

2.create a folder say "apps" in your c:(hard disk) if you are using Windows.Exactly this way. C:\apps

3.Save all your source files in that apps folder.

4.Go to your environment variable and create a classpath variable under "user variables for ..."

Click on the new button, under variable name and type "classpath" (without the quotes)
under "variable value",supply the mysql connector/j driver exactly like this with the jar file at the end. C:\mysql-connector-java-x.x.xx\mysql-connector-java-x.x.xx-bin.jar(x marks the version number)

5.click ok.

6.Set the path for your jdk so that you don't keep setting it over and over each time you want to run your program.

C:\program files\java\jdk1.x.x\bin copy this address path from your windows explorer's address bar and put a semicolon (;) before pasting it in the path. You have to do this in your path system variables else,you will end doing this each tme you want to execute some codes.

```
cd\
cd apps (enter)
set classpath=(enter)
set path=c:\program files\java\jdk1.x.x\bin(enter)
javac ClassName.java(enter)
java ClassName(enter)

```

(Am so sure you don't want that all the time )
Now to compile,open your command prompt and change directory to your apps directory and type javac to test if your configs did work.You will get a list of the javac options.If you did then you are on the right track again.

open your jdbc code make sure these are rightly coded.

```
Class.forName("com.mysql.jdbc.Driver");
 conn = DriverManager.getConnection("jdbc:mysql://localhost:portnumber/test","username","password");

```

compile and run your code again.
Let me know if this helped you
You can't set the directory in the classpath, you either need to specify "\*.jar" under the directory, or specify each jar by name.