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 Getting There Packages

Bad source file?

Hi I'm not sure how to fix this error

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); }
}

the console says

Example.java:1: 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.

2 Answers

Andrew Winkler
Andrew Winkler
37,739 Points

Example.java:1: error: cannot access Treet import com.teamtreehouse.Treet; ^ bad source file: ./com/teamtreehouse/Treet.java

This error response means that in your workspaces you never created a Treet.java file as a child of the teamtreehouse folder. The file structure should go something like this Java Data Structures – Class Review > com > teamtreehouse > Treet.java. Trace your file structure to see if you misspelled something or left something out.

If it's not blatantly apparent, I would suggest downloading the project files .zip folder for cross-referencing. If all else fails, you may have to delete and recreate the workspace -- the rest assured if you troubleshoot via the first two methods that I've mentioned I'd estimate it's 97% likely that you'll find it to be a simple fixable typo.

Please to remember to vote best answer if this helps! Happy coding!

Kyle Baker
Kyle Baker
8,211 Points

I'd just like to add that you get a similar error if you're dealing with packages. Mine was due to not having package com.teamtreehouse.model; at the top of my Team.java file. Since I got to this page by copying and pasting my own error, I hope that this will prove helpful to somebody someday.