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
Error at runtime : "Error: Could not find or load main class TestClass"
Moderator: admin
-
- Posts: 3
- Joined: Fri Feb 08, 2019 11:47 am
- Contact:
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.827 :
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.
-
- Posts: 3
- Joined: Fri Feb 08, 2019 11:47 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.827 :
Yes sir, and it compiled well
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.827 :
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.
-
- Posts: 3
- Joined: Fri Feb 08, 2019 11:47 am
- Contact:
Re: Error at runtime : "Error: Could not find or load main class TestClass"
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
C:\Users\xcxc\Desktop\Java\exceptions>java TestClass
Error: Could not find or load main class TestClass
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Error at runtime : "Error: Could not find or load main class TestClass"
post the exact java file contents.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 119 guests