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 Class Review

Guillaume Crt
Guillaume Crt
6,395 Points

Problem compiling Example.java : file not found

when I compile Example it says that the file is not found, any help ?

I already checked that the file is outside the package teamtreehouse

6 Answers

Sandro Müller
Sandro Müller
1,089 Points

Hey guys. I had some similar problems at the beginning, so I would like to make sure, everybody with the same question can fix it. :)

1) You have a folder <com> 2) You have a file "Example.java"

In the <com>-folder there is <teamtreehouse>folder. In that <teamtreehousefolder> there is a "Treet.java"-file.


If you made sure that is correct, but it still does not work, let's check some other stuff that is important to make it work.

In your "Example.java"-file you should have imported: import com.teamtreehouse.Treet;

The very first line of your "Treet.java"-file shoul be: package com.teamtreehouse;


Well, if it still does not work, there is more you can do. When compiling the files with: clear && javac Example.java && java Example make sure you run the code from the right folder.

If you go to the console and type: "ls" it should show: (type ls) com----Example.class----Example.java

If that is the case, it should work. If you type in "ls" in the console, but get something else, you have created more folders than you supposed to and hence need to change the directory with cd. You can read online about how to do that.

Hi Guillaume,

Did you check that the file is outside the com directory?

├── com
│   └── teamtreehouse
│       └── Treet.java
└── Example.java
Guillaume Crt
Guillaume Crt
6,395 Points

Hi that's exactly what I had, I checked multiple times and create others files like examples but it didn't work. Finally I let it go because I get the point about what it means

I'm having the same issue. Spelling is correct, Example.java is in com but outside teamtreehouse and Treet.java inside teamtreehouse. Example has import com.teamtreehouse.Treet; and Treet has package com.teamtreehouse; . Still getting file not found error.

The file (Example.java) needs to be outside the com directory?

├── com
│   └── teamtreehouse
│       └── Treet.java
└── Example.java

make sure that the file is outside the com.treehouse package and that you have saved it

Bert Peters
Bert Peters
2,484 Points

Hello,

Has everybody solved his file not found issue ? I can't seem to resolve it ?

I'm experiencing the same problem I think. Although I have the Treet class in the Treet.java file, the compiler says it is not there ?

My workspace compiler says:

Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
./com/teamtreehouse/Treet.java:2: error: class, interface, or enum expected
package com.teamtreehouse;
^
Example.java:2: error: cannot access Treet
import com.teamtreehouse.Treet;
^
bad source file: ./com/teamtreehouse/Treet.java
file does not contain class com.teamtreehouse.Treet
Please remove or make sure it appears in the correct subdirectory of the sourcepath.