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 Annotations Using Java's Built-In Annotations The @Override Annotation

Code not compiling

I downloaded the source files because the workspace was not loading.

When I created the Cheese.java file, made the changes in the video and tried to compile Main.java with javac I got the following error:

Main.java:5: error: cannot find symbol
        Cheese myCheese = new Cheese();
        ^
  symbol:   class Cheese
  location: class Main
Main.java:5: error: cannot find symbol
        Cheese myCheese = new Cheese();
                              ^
  symbol:   class Cheese
  location: class Main
2 errors

Here is what my Main.java file looks like:

package com.teamtreehouse.override;

public class Main {
    public static void main(String[] args) {
        Cheese myCheese = new Cheese();
        System.out.println(myCheese);
    }
}

and my Cheese.java file:

package com.teamtreehouse.override;

public class Cheese {
    public String toString(String something) {
        return "Cheezy";
    }
}

I've also tried opening the project in IntelliJ and it won't even let me run the Main.java file or the project.

Any help would be much appreciated.

3 Answers

Zachary Miles
Zachary Miles
5,377 Points

When you import a project there are a couple of things you need to do. 1) Right-click on the "src" folder and mark directory as sources root 2) Select SDK under File -> Project Structure 3) Create an "out" folder to store all project compilation results and define the path under File -> Project Structure -> Project compiler output (should create a folder named "out" and include in your file path EX: C:\Users\user\IdeaProjects\Java Annotations\out)

I have the same issue but I can't open it in Intellij because the code won't download