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
pooria shahbeigi
388 PointsI get this Error: Could not find or load main class Introductions.java
I get this Error: Could not find or load main class Introductions.java import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is Peter\n");
console.printf("Peter learning how to code\n");
} }
treehouse:~/workspace$ javac Introductions.java
treehouse:~/workspace$ java Introductions.java
Error: Could not find or load main class Introductions.java
treehouse:~/workspace$
2 Answers
Ivan Kazakov
Courses Plus Student 43,317 PointsHey,
you add the extension (.java) when compiling the class: javac Introductions.java, but you should not add it when running the compiled class: java Introductions (but NOT java Introductions.java)
Jeremy Hill
29,567 PointsMake sure that there are curly braces "{}" wrapped around your class and main method:
public class ExampleClass{
public static void main(String[] args){
//code goes here
}
}
pooria shahbeigi
388 PointsThanks for your reply, actually I have the curly braces and still get this error message.
pooria shahbeigi
388 Pointspooria shahbeigi
388 PointsAwesome, Thanks .