I am facing an error when run the below java program on windows command prompt. Basically, I am a C/C++ programmer , but i need to run a java file as a part of some testing..
Following is the content of my TestClass.java, not copied full code as it looks like some kind of path or package issue.
package parse_signature;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class TestClass {
public static void main(String[] args) throws IOException {
String path_of_file= "input/content.txt";
BufferedReader reader = new BufferedReader(new FileReader(path_of_file));
String line;
while ((line = reader.readLine()) != null) {
....
}
}
I am in the directory: C:/Users/Desktop/JavaPRGs/Test/, when i used the command javac TestClass.java,
TestClass.class got created and when i run java TestClass
I get following error:
Error: Could not find or load main class TestClass
Caused by: java.lang.NoClassDefFoundError: parse_signature/TestClass (wrong name: TestClass)
I tried going back to previous directory C:/Users/Desktop/JavaPRGs and ran java Test.TestClass
got the same error (only this difference wrong name: Test/TestClass)
Also tried follwing, but the result is same.
C:\Program Files\Java\jdk-12.0.1\java -cp . Test.TestClass