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 Basics Using your New Tools Multiple Strings

Despite my best efforts I'm doing something wrong? (Error: Could not find or load main class TreeStory.java)

If I'm doing this right here's what I have, with a completed section following shortly.

import java.io.Console;

public class TreeStory {

    public static void main(String[] args) {
        Console console = System.console();
        /*  Some terms:
            noun - Person, place or thing
            verb - An action
            adjective - A description used to modify or describe a noun
            Enter your amazing code here!
        */        

    }

}

Here's when I get it all typed up. I run a java compiler with no issues then when attempting to run the actual java Program I return the error Error: Could not find or load main class TreeStory.java

import java.io.Console;

public class TreeStory {

    public static void main(String[] args) {
        Console console = System.console();
        /*  Some terms:
            noun - Person, place or thing
            verb - An action
            adjective - A description used to modify or describe a noun
            Enter your amazing code here!
        */    
        String name = console.readLine("Enter your name:  ");
        String adjective = console.readLine("Enter an adjective:  ");
        console.printf("%s is very %s", name, adjective);

    }

}

3 Answers

Hi Bryce,

I get this same error when trying to execute the following at the console prompt:

treehouse:~/workspace$ java TreeStory.java

Once the program has been compiled, when we go to run it, leave off the file extension for TreeStory.

treehouse:~/workspace$ java TreeStory

This is invoking the JVM (Java Virtual Machine) on the file TreeStory.class, which was the output from the compilation step.

Hope this helps,

Cheers

Alvaro Gutierrez
Alvaro Gutierrez
1,471 Points

Try entering: clear && javac TreeStory.java && java TreeStory

WOW! What a silly thing I was doing here! I can't believe it. Usually I can analyze my mistake over several passes of thought. However, sometimes I analyze a problem way too close, and I over think the easiest possible solutions. Thanks for pointing out my silly! Cheers.

For me, it was a matter of capitalizing the "S" in TreeStory. My corrected compilation request for the console was: javac TreeStory.java

Hope that helps.