Error at runtime : "Error: Could not find or load main class TestClass"

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
cunha96
Posts: 3
Joined: Fri Feb 08, 2019 11:47 am
Contact:

Error at runtime : "Error: Could not find or load main class TestClass"

Post 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

admin
Site Admin
Posts: 8944
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.827 :

Post 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?
If you like our products and services, please help us by posting your review here.

cunha96
Posts: 3
Joined: Fri Feb 08, 2019 11:47 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.827 :

Post by cunha96 »

Yes sir, and it compiled well

admin
Site Admin
Posts: 8944
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.827 :

Post 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.
If you like our products and services, please help us by posting your review here.

cunha96
Posts: 3
Joined: Fri Feb 08, 2019 11:47 am
Contact:

Re: Error at runtime : "Error: Could not find or load main class TestClass"

Post 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

admin
Site Admin
Posts: 8944
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Error at runtime : "Error: Could not find or load main class TestClass"

Post by admin »

post the exact java file contents.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Mar_92 and 7 guests