0

The error image

Error: Could not find or load main class JDBCExample1.java

Caused by: java.lang.ClassNotFoundException:JDBCExample1.java

Batch file used:
set path=C:\Program Files\Java\jdk-10.0.2\bin;
set classpath=C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc14.jar;.
javac JDBCExample1.java
java JDBCExample1.java
pause

The PATH and the CLASSPATH have been set correctly in Environment variables too.

Also the directory used is correct.

  • I have saved the program JDBCExample1.java in the folder named JDBCODBCprograms which is saved on my Desktop. So I am using : cd C:\Users\Siddhi\Desktop\JDBCODBCprograms to set the directory – Priyank Patil Sep 30 '18 at 14:29
  • the porblem is bei running java compiler javac you gnerate a new file. This new file can be run using javac not the source code file – jan-seins Sep 30 '18 at 15:03
  • In general replacing __local__ `PATH` by a user defined `PATH` not containing anymore Windows system directory path is no good idea on using a batch file as it can be read on answer on [What is the reason for '...' is not recognized as an internal or external command, operable program or batch file?](https://stackoverflow.com/a/41461002/3074564) I suggest to use in your batch file `set "PATH=C:\Program Files\Java\jdk-10.0.2\bin;%PATH%"`. – Mofi Sep 30 '18 at 17:16

1 Answers1

0

Try giving “java JDBCExample1” Instead of “java JDBCExample1.java” In the last line. One does not use .java while running the program

KPS
  • 31
  • 2