Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Getting There Type Casting

Open Treet.java in JShell

Hello! I have a very basic question about JShell. In the video, Craig used Java REPL, which I assume does about the same thing as JShell does. I tried to follow along in JShell, since that's the REPL I've got used to and have been using since I started learning Java. However, I couldn't quite figure out how to open Treet.java. I tried "/open com/teamtreehouse/Treet.java", which I figured would be the most reasonable command. But it gives me this error message:

Error: 
Illegal start of expression 
package com.teamtreehouse;
^

After a few google searches, I understand that the command I used to open the file supposedly should work, so now I need help figuring out what mistakes I've made and what is the correct way to open a file in a package.

Thanks in advance!

3 Answers

Bump. Having the same issue, I know this is old but it never got an answer.

John Reese
John Reese
1,151 Points

Try commenting out "package com.teamtreehouse;" from the top of the file Treet.java (// will comment a line out), and then:

/open com/teamtreehouse/Treet.java

in jshell.

Andrew Menning
Andrew Menning
10,050 Points

You can import the Treet class using the following line inside jshell:

jshell> import com.teamtreehouse.Treet