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 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:

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