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 Data Structures - Retired Getting There Packages

Sean Flanagan
Sean Flanagan
33,235 Points

Error messages

Hi. I typed in the code. Treet.java:

package com.teamtreehouse;

public class Treet {

}

Example.java:

import com.teamtreehouse.Treet;

public class Example {
  public static void main(String []args) {
    Treet treet = new Treet();
    System.out.printf("This is a new Treet: %s %n", treet);
  }
}

On the console, I typed:

clear && javac Example.java && java Example

I got this message:

"Example.java:1: error: cannot find symbol
import com.teamtreehouse.Treet;
^
symbol: class Treet
location: package com.teamtreehouse
error: Class names, 'Example', are only accepted if annotation processing is explicitly requested Example.java:5: error: cannot find symbol
Treet treet = new Treet();
^
symbol: class Treet
location: class Example
Example.java:5: error: cannot find symbol
Treet treet = new Treet();
^
symbol: class Treet
location: class Example
4 errors"

Does anyone have any idea why this is happened and how I can fix it please?

Thanks

Sean :-)

9 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Found it!

Thanks for forking your workspace. Your Treet.java file is lowercased. This fixes it:

treehouse:~/workspace$ mv com/teamtreehouse/treet.java com/teamtreehouse/Treet.
java
Sean Flanagan
Sean Flanagan
33,235 Points

It's working! Thanks Craig; that was a big help! And thank you too Pedro. :-)

No, it's fine as it is. I'm just not explaining myself properly maybe. In your folder "com/teamtreehouse" you should have two files: Treet.java and Treet.class, do you have this last one? - I think the problem relies here. Overall you will want two have a total of 4 files: 2 with the java code you wrote yourself Example.java and Treet.java and two generated by the java compiler (javac) which will be named Example.class and Treet.class: the first two will reside on the root folder of your project and the last two in "com/teamtreehouse".

Make sure you have a Treet.class inside your "com/teamtreehouse" folder - which is the bytecode generated by the compiler.

Did you running the code I wrote gave any output?

Sorry if I'm being a bit confusing.

Sean Flanagan
Sean Flanagan
33,235 Points

No I haven't got a Treet.class file.

I see the problem, you named your file treet.java when it should be Treet.java with a capital T. After that, if you run: javac com/teamtreehouse/Treet.java && javac Example.java && java Example it all works.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Is Treet.java in the com/teamtreehouse/ folder?

The compile error you are getting is associated to compiling a program and forgetting the .java extension, try to compile Treet.java again with javac Treet.java and see if the rest of the program is working.

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Pedro. Thanks for your help. Both my Treet and Example files have the .java extension, and Treet.java is in the com/teamtreehouse folder. I tried to compile Treet.java with: clear && javac Treet.java && java Treet and I got this message:

javac: file not found: Treet.java
Usage: javac <options> <source files>
use -help for a list of possible options

From the error you are getting (file not found) I assume that you are either running the command on the wrong directory or not specifying the path to the file, since the file does actually exist. I would suggest the following, from the terminal:

  1. Navigate to the folder where your Example.java is located
  2. Run the following code: clear && javac com/teamtreehouse/Treet.java && javac Example.java && java Example

I understand that your files both have the .java extension, what I implied in my initial post was that when you compiled your Treet you might have missed the extension the javac command and not in the file itself - I might be wrong though, just trying to troubleshoot.

I hope it helps.

Sean Flanagan
Sean Flanagan
33,235 Points

Hi again Pedro. I know you're trying to help and I'm very grateful. My Example.java isn't in the com folder or the teamtreehouse folder. Should it be in one of these?

Thank you :-)

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Can you fork your workspace and share it? We'll figure it out!

Sean Flanagan
Sean Flanagan
33,235 Points

I've forked my workspace and taken a snapshot. Here it is:

https://w.trhou.se/6ddpi33kw3

Thanks

Joe Law
Joe Law
5,040 Points

Hi Craig Dennis , I am having the same error here, do you mind to have a look here? I had forked my workspace. This is my snapshot, http://w.trhou.se/kbmshqq95q Thanks Craig!

CC Sean Flanagan

Hi all. It wasn't working for me as well a few days ago with the %n character and I changed it to the \n. But now it is working with the %n character. Good luck!