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 trialSoumyadeep Mukhopadhyay
1,772 PointsProblems with REPL
In repl why am i having "ERROR - Cannot find symbol" whenever i pass these commands PezDispenser pD = new PezDispenser("Broda"); PezDispenser.MAX_PEZ; ??
Here is the snapshot of my work space - https://w.trhou.se/5u6chdd2fk
THANKS IN ADVANCE!!
5 Answers
typetypetypetype
Courses Plus Student 1,033 PointsI did, thank you, I posted in another thread where someone solved it, we had comments in our workspace and that was giving the error when running the line in question.
Chris Ramacciotti
Treehouse Guest TeacherIf you have a link to that question, can you post it here and we'll mark it as best answer? 12pts! :)
typetypetypetype
Courses Plus Student 1,033 Pointshttps://teamtreehouse.com/community/declaring-new-variable-and-got-error-cannot-find-symbol
Maybe you don't want me to Chris, it shows your staff hasn't fixed the bug in over a year >_> / :P
Soumyadeep Mukhopadhyay
1,772 PointsI kind of agree with typetypetypetype, this is surely a bug. Thanks a lot typetypetypetype. Although i had to delete all my comments but i could get my problem solved.
Chris Ramacciotti
Treehouse Guest TeacherThank you both for your comments! After careful research, it appears that this is a bug in a third-party library we use for that REPL tool. I just found through a series of tests that a comment containing class
followed by a valid Java identifier wouldn't be parsed correctly with the :load
command. I've filed an issue here:
Soumyadeep Mukhopadhyay
1,772 PointsI was just curious about this repl, is the load command designed to read codes one after another like, line by line or was there no provision to detect the "//" symbol. Thanks a lot Chris for being so helpful but i expected it a bit earlier, anyways i am very happy in your response. Thank you.
Chris Ramacciotti
Treehouse Guest TeacherThe :load
command can parse full source files in general, even with comments. It seemed that as long as "class" didn't appear in a comment followed by a valid identifier, that parsing would succeed.
Chris Ramacciotti
Treehouse Guest TeacherHello! I forked your workspace, and everything compiled and ran for me. Have you since fixed this problem?
Soumyadeep Mukhopadhyay
1,772 PointsI am sorry Chris but this is what I am still getting after PezDispenser pd = new PezDispenser("Yoda"); this code is:
ERROR: cannot find symbol
symbol: class PezDispenser
location: interface Evaluation
PezDispenser method$hnp61skfrv8yt3l749wu();
^
Chris Ramacciotti
Treehouse Guest TeacherWhat you're running into seems to be a shortcoming of a third-party tool, and one that, while useful in the initial learning process of Java, has limitations. My recommendation would be to work around its shortcomings by omitting comments that include the keyword class
, or even better, use the command line to compile and run your source code in Workspaces, using the standard approach of a public static void main(String[] args)
method. If you're working through the Learn Java Track or the Java Web Development Techdegree, soon you'll get to the Local Development Environments course. This will guide you through setting up your own machine for coding in Java. Once you do that, you'll probably never go back. :)
Gaurav Munjal
Courses Plus Student 2,390 PointsHi Chris,
Shall we compile and then load, or loading automatically compiles the source, not sure how repl works, does it compiles the line to be evaluated at a time ?
Thanks
typetypetypetype
Courses Plus Student 1,033 Pointstypetypetypetype
Courses Plus Student 1,033 Points'''java> PezDispenser pd = new PezDispenser("Yoda");
'''
I also ran into the issue, that is my input line, it looks like you ran into it sooner than I did in the problem set.