After installing Oracle 11g R2 on my system, I set the environment variable as following:
variable Name :CLASSPATH
variable Value :E:\app\JamesPJ\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar
Variable name : ORACLE_HOME
varaible value :E:\app\JamesPJ\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar
When I run the program using testpad and in command prompt the error comes as follows :
Error: Could not find or load main class test
How is this caused and how can I solve it?
Java looks in the classpath for all classes. You’ve however set the classpath to a single fixed JAR file which is the JDBC driver itself. This JAR file surely doesn’t contain your own
test.classfile. Provided that yourtest.classis available in the current working directory, you should have added the current working directory.to the classpath.Note that the paths in the classpath are semi colon separated in Windows and colon separated in *nix.
Alternatively, you could also just control the classpath during execution by the
-cpargument. This way the environment variable will be ignored altogether.To avoid the tedious work of re-entering the whole command everytime, put it in a
.bator.cmdfile and execute it instead.