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 Type Casting

Sølvi Qorda
Sølvi Qorda
14,194 Points

Unable to import the Treet.java file in the repl

When I open the repl and type the commands Craig provides, it works until I try to import com.teamtreehouse.Treet

It tells me that it cannot find symbol, and it points to the period before Treet.

Any ideas? I couldn't make sense of anything on stack overflow...

Thanks in advance. :)

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Is your Treet.java file in the relative directory "./com/teamtreehouse/"? If it is in our current working directory, you can try to use "import Treet".

Sølvi Qorda
Sølvi Qorda
14,194 Points

Hi Chris,

Thanks for your help, when I type import .com/teamtreehouse/Treet.java;

I get a 'Does not exist'. It's definitely in the working directory, I can see it on the left under teamtreehouse

5 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

In the video, Craig is in the ~/workspaces directory which has three items: a directory com, Example.class and Example.java. He then does two steps to import Treet in the java-repl: load file, then import:

$ java-repl
Welcome to JavaRepl version 272 (Java HotSpot(TM) 64-bit Server VM, Java 1.8.0_20)
Type expression to evaluate, :help for more options or press tab to auto-complete
java> :load com/teamtreehouse/Treet.java
Loaded source file from com/teamtreehouse/Treet.java
java> import com.teamtreehouse.Treet;
Imported com.teamtreehouse.Treet

What are you experiencing that is different in your case?

ibrahim dirir
ibrahim dirir
11,290 Points
Welcome to JavaREPL version 303 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_65)             
Type expression to evaluate, :help for more options or press tab to auto-complete.             
java> :load com/teamtreehouse/Treet.java                                                       
Loaded source file from com/teamtreehouse/Treet.java                                           
java> import com.teamtreehouse.Treet;                                                          
java.util.NoSuchElementException

everything seems okay to me i don't know why am getting this error. i am stuck here for a whole week.

ibrahim dirir
ibrahim dirir
11,290 Points

Loaded source file from com/teamtreehouse/Treet.java
java> import com.teamtreehouse.Treet;
java.util.NoSuchElementException
java> import com.teamtreehouse.Treet;
i am getting this error

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Can you add the full session log? Please include a directory listing of ~/workspaces

ibrahim dirir
ibrahim dirir
11,290 Points

com/teamtreehouse/Treet and my Example.java is in the default package

ottozov
ottozov
2,266 Points

I found the issue. Double check your Treet.java and Example.java files and make sure Example compiles without warnings.