Re: ClassNotFoundException
The required jar file needs to be put somewhere where you can refer to it when you compile and run your code. For this simple example you might put it in the same folder that you have Example1.java
Then you can compile and run with the following (cd to the directory containing the code first)
Code:
javac -cp .;ojdbc14.jar Example1.java
java -cp .;ojdbc14.jar Example1
The thing following -cp is the classpath. If you are on *nix use : rather than ; as shown (which is for Windows). The dot means "look for classes in the current directory" and "ojdbc14.jar" means "look for classes in the ojdbc14.jar archive". You can specify any number of locations this way, each one separated by ; (or :).
-----
I have added code tags to your post. The thing is when you post code put [code] and [/code] at the end so that formatting is preserved.
Re: ClassNotFoundException
If you have oracle Database, go to oracle install folder and search for ojdbc14.jar file.
If you found that, copy the jar file location and Right click on the MyComputer Icon---->properties----->Advanced tab---->Environment Variables----->in the user variables click on new button---->variable name:CLASSPATH
variable value:.;past that url here; (ex: variable value=,;C:\oraclexe\app\oracle\product\10.2.0\serv er\jdbc\lib;)
----->ok--->ok---->ok
this is the permenent path setting no need to add classpath every time.
Re: ClassNotFoundException
Quote:
Originally Posted by
pbrockway2
The required jar file needs to be put somewhere where you can refer to it when you compile and run your code. For this simple example you might put it in the same folder that you have Example1.java
Just a nitpick, but in this case you don't actually need it for the compiling, just at runtime, since the oracle code is not referenced directly, just via a String.
Quote:
Originally Posted by
RameshPadamati
If you have oracle Database, go to oracle install folder and search for ojdbc14.jar file.
If you found that, copy the jar file location and Right click on the MyComputer Icon---->properties----->Advanced tab---->Environment Variables----->in the user variables click on new button---->variable name:CLASSPATH
variable value:.;past that url here; (ex: variable value=,;C:\oraclexe\app\oracle\product\10.2.0\serv er\jdbc\lib;)
----->ok--->ok---->ok
this is the permenent path setting no need to add classpath every time.
And this is just wrong.
You do not muck with the environment variables.
It is not the correct way to handle a java projects classpath.
You use the method given by pbrockway2, or via your IDE on a per project basis.