I started using JDBC so I went to Classpath, changed it to classpath of OracleDriver and program compiled. There was classpath set earlier there which I did not bother to check.Now, the program can compile but I am not able to run it.This is the error message I am getting:
Could not find or load main class 'classname that I am trying to run'
Any idea what's wrong?
After you compile, there are generated .class
files that get made from the .java
files.
When you want to run, you need the generated .class
files on the path, so find the directory where they live, and add that directory to the class path.
Note that if you define a class as
package com.corp.myproduct;
public class Sifter {
}
It will generate to a path of
<root>/com/corp/myproduct/Sifter.class
or on windows
<root>\com\corp\myproduct\Sifter.class
where root is the "top level directory" of the compiled output. You don't add <root>/com/corp/myproduct/
in such a case to the classpath, you just add <root>
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.