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!

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

Could not find or load main class TreeStory.java

When i run the program i get the error Could not find or load main class TreeStory.java

Here is the code

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!
    */

int age = 12 ; if (age < 13 ) {console.printf("Age resticted "); System.exit(0);} String name = console.reaLine("Enter a name : "); String noun = console.reaLine("Enter a noun : "); String verb = console.reaLine("Enter a verb : "); String adverb = console.reaLine("Enter an adverb : "); String adjective = console.reaLine("Enter an adjective : ");

console.printf("Your Treestory :\n---------------\n"); console.printf("Your Treestory : %s is a %s %s, name adjective,noun "); console.printf("They are always %s %s \n",adverb,verb);

}

}

4 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

I think you might be typing

java TreeStory.java

Remember you do not include the .java extension when running the program. You should type:

java TreeStory
Lee Reynolds Jr.
Lee Reynolds Jr.
5,160 Points

You aren't typing "readLine". You're typing "reaLine".

When i change reaLine to readLine i get the following error error: Class names, 'TreeStory', are only accepted if annotation processing is explicitly requested

Nigel Doyle
Nigel Doyle
668 Points

I had the same problem. Took me a few minutes to realise that it's all case sensitive. Also remember to save it every time, especially after correcting (my) many errors.... so: javac TreeStory.java java TreeStory

I'm learning!

Nigel.