Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects (Retired) Meet Objects Constructors

could not load main class

Im having problems when I try to compile and run my Pez Dispenser i get an error that says:

Error: Could not find or load main class Example.java

I can see the Example.java work I have done but when I type:

clear && javac Example.java && java Example.java I get that error.

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Timothy;

Try:

treehouse:~/workspace$ clear && javac Example.java && java Example

You don't need the .java extension on the file name when you run it with the java command line command. This was covered in the Java Basics course I believe during the demonstration as to how to properly run our programs during that course.

Hope it helps and happy coding,

Ken

Yup, that was it. After typing it again i remembered. Thanks so much for your help!

Awesome, I got the same error. Thanks for the tip, Mr. Alger.

Ken Alger
Ken Alger
Treehouse Teacher

Mr. Donche;

Welcome to Treehouse!

I hope you enjoy your coding experience.

Ken