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 Meet Objects Creating Classes

Billy Lardizabal
Billy Lardizabal
5,017 Points

Cant run any java files in Workspace! Error: Could not find or load main class Example.java

I can't run any java files in Workspace. It seems to compile right, because "javac Example.java" seems to run okay. But when I enter "java Example.java" it throws an error saying "Error: Could not find or load main class Example.java". whats happening?! It even randomly created an image file when I tried to run last courses' code

2 Answers

Billy Lardizabal
Billy Lardizabal
5,017 Points

I was running "treehouse:~/workspace$ clear && javac Example.java && java Example.java" like in the out dated lesson, instead of treehouse:~/workspace$ clear && javac Example.java && java Example". Now it works fine!

Victor Utama
Victor Utama
6,934 Points

Yup. That's the answer. It works now. Thanks Billy Lardizabal