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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Michel Spaniolo](https://secure.gravatar.com/avatar/9327d069dbbd5a6e3e217e5dbb25846f?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Michel Spaniolo
Courses Plus Student 1,850 PointsYes im having trouble compiling.Maybe a hint at what im doing wrong would and has helped
https://w.trhou.se/l8316r5n3u Im getting an error when compiling that references the dispenser but i dont see the problem if that is the problem
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe compiler tries to identify the problems and tell you in the error messages. Some examples:
-
error: non-static variable MAX_PEZ cannot be referenced from a static context
So you need to add the "static" keyword where that variable is declared on line 2 of PezDispenser.java -
Example.java:12: error: cannot find symbol
dispenser.swapHead
The "swapHead" method that was previously in PezDispenser.java in your previous question has been removed, but it is still being called on line 12 of Example.java. Either remove the call (as in the video), or put the method back. -
Example.java:16: error: cannot find symbol
dispense.isEmpty
This time it's a spelling error with "dispense" instead of "dispenser"
The other errors are similar, either spelling or a call to a method that was removed. I bet you can find and correct the rest of them by using the error messages now.
![Michel Spaniolo](https://secure.gravatar.com/avatar/9327d069dbbd5a6e3e217e5dbb25846f?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Michel Spaniolo
Courses Plus Student 1,850 PointsI cleared out the swapHead method and it says theres still 1 error..the code runs only 2 lines..https://w.trhou.se/rp9piy63ca
Steven Parker
230,688 PointsSteven Parker
230,688 PointsRemember to pay attention to the compiler error messages, they will attempt to show exactly where the error is.
The compiler now points to a "catch" statement that seems to have no corresponding "try" in the code.
Also, the "error: reached end of file while parsing" often indicates unmatched parentheses or braces, and in this case there seems to be no closing brace for the class itself.
Some of the spelling errors still need to be corrected.
And as long as you have compiler errors, running the program won't give you any useful information since you are running an old version (from the last successful compile).