Page 1 of 1
Error at runtime : "Error: Could not find or load main class TestClass"
Posted: Tue Mar 12, 2019 8:54 am
by cunha96
Hello, when I run the following code on cmd appears the following at runtime : "Error: Could not find or load main class TestClass" , don't understand exactly why it prints that, from my point of view main class is fine and code would print "Exception from foo", can someone illuminate me please ?
Thank you
Re: About Question enthuware.ocajp.i.v8.2.827 :
Posted: Tue Mar 12, 2019 9:07 am
by admin
The error is thrown by the jvm and means that it is not able to find the class for TestClass. Did you compile TestClass.java first?
Re: About Question enthuware.ocajp.i.v8.2.827 :
Posted: Tue Mar 12, 2019 9:11 am
by cunha96
Yes sir, and it compiled well
Re: About Question enthuware.ocajp.i.v8.2.827 :
Posted: Tue Mar 12, 2019 9:24 am
by admin
May be there is a typo in the class name or there is a package statement. Difficult to say because you haven't posted any code.
Re: Error at runtime : "Error: Could not find or load main class TestClass"
Posted: Tue Mar 12, 2019 9:32 am
by cunha96
C:\Users\xcxc\Desktop\Java\exceptions>javac TestClass.java
C:\Users\xcxc\Desktop\Java\exceptions>java TestClass
Error: Could not find or load main class TestClass
Re: Error at runtime : "Error: Could not find or load main class TestClass"
Posted: Tue Mar 12, 2019 11:32 am
by admin
post the exact java file contents.