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 trialJonathan Grieve
Treehouse Moderator 91,253 PointsjShell isn't finding the PezDispenser object.
Hi all.
So I'm following the video okay, but I can't seem to get jShell to follow the demo properly. This is what I keep getting in the console.
jshell> .open PezDispenser.java
| Error:
| illegal start of expression
| .open PezDispenser.java
| ^
So I guessed again and opened it with
jshell> /open PezDispenser.java
So I got into the program and found this when I tried to create a new instance.
jshell> PezDispenser pd = new PezDispenser("Yoda");
| Error:
| cannot find symbol
| symbol: class PezDispenser
| PezDispenser pd = new PezDispenser("Yoda");
| ^----------^
| Error:
| cannot find symbol
| symbol: class PezDispenser
| PezDispenser pd = new PezDispenser("Yoda");
I don't think it matters too much that I can't follow along if I'm understanding it mostly but I thought I'd ask, see if anyone else is having the same trouble.
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Craig,
Yes sure here's the link :)
When I tried it earlier I actually bypassed one of the steps
/open PezDispenser
I tried again and it returned this
jshell> /open PezDispenser
| File 'PezDispenser' for '/open' is not found.
jshell> /open PezDispenser.
| File 'PezDispenser.' for '/open' is not found.
jshell>
Still some gremlins in there! :)
Craig Dennis
Treehouse TeacherHmmm...
jshell> /open PezDispenser.java
jshell> PezDispenser pd = new PezDispenser("Yoda");
pd ==> PezDispenser@56ef9176
jshell> pd.isEmpty();
$3 ==> false
Jonathan Grieve
Treehouse Moderator 91,253 PointsSo the snapshot worked when you tried it? Hmmm indeed.
I wonder if there's some sort of network problem my end that's causing it. I had similar problems trying to interact with Telnet in another course.
Or have I got access to a different version of the shell in workspaces?
Craig Dennis
Treehouse TeacherTry typing that exactly...there is literally no difference.
6 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Craig,
Okay so I think it's working now, but I'm pretty sure the command at the top here is supposed to do something i.e. list the class and java file associated with the workspace
jshell> /open PezDispenser
| File 'PezDispenser' for '/open' is not found.
jshell> /open PezDispenser.java
jshell> PezDispenser pd = new PezDispenser("Yoda");
pd ==> PezDispenser@56ef9176
jshell> pd.isEmpty();
$3 ==> false
But maybe I misunderstood that. :)
So it looks like I tried it the same way as my OP but I'm still not sure why it didn't work the first time. Anyway thanks for looking into it! :)
Craig Dennis
Treehouse TeacherYeah that open command is relative file based only.
Melody P
801 PointsI'm having similar issues. I noticed that when I type it in the second time, jShell seems to take it in okay, but then when I type in PezDispenser pd = new PezDispenser("Yoda");
jShell doesn't take. jShell just tells me that it cannot find symbol, specifically the symbol: class PezDispenser
which doesn't make sense at all.
Jack Cummins
17,417 PointsYou gave your self a best answer! Is that allowed?
ian weiss
2,940 PointsI had the same problem Melody P but when I scanned through my code several more times i found that I had spelled "boolean" as "bolean" at this point in my code ----> public bolean isEmpty(){ once i corrected my spelling error, saved the file, and tried it again everything worked as planned.
Christopher Mlalazi
Front End Web Development Techdegree Graduate 17,305 PointsSo did you finally find the solution guys I have hit the same problem.
Christopher Mlalazi
Front End Web Development Techdegree Graduate 17,305 PointsI finally got it too was using String instead of Boolean I guess I am still new in java.
renzohoogendoorn
1,804 PointsIt only seems to happen when you have a syntax error somewhere in your PezDispenser.java file :).
Alessandro Agostinelli
2,174 Pointsi'm having the same issue aswell
heres my workspace https://teamtreehouse.com/workspaces/28115042#
Jack Cummins
17,417 PointsBroken link.
Craig Dennis
Treehouse TeacherCraig Dennis
Treehouse TeacherHey Jonathan!
Can you snapshot your workspace please? I'll try and debug...
/open PezDispenser.java
Should give you access to the type.