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

Printer class not recognized by PrinterTest

Hey all,

I'm getting exceptions in the provided code that suggest the Printer class is not being recognized by the PrinterTest class. I'm a little out of practice with Java... I haven't changed anything about the provided file structure in the project. Is there something obvious that I'm missing?

Exceptions:

~/lcc-java-fp-printer-1.1.0/src/test/java/com/teamtreehouse/challenges/PrinterTest.java
Error:(31, 39) java: cannot find symbol
  symbol:   class Printer
  location: class com.teamtreehouse.challenges.PrinterTest
Error:(53, 5) java: cannot find symbol
  symbol:   variable Printer
  location: class com.teamtreehouse.challenges.PrinterTest
Error:(54, 5) java: cannot find symbol
  symbol:   variable Printer
  location: class com.teamtreehouse.challenges.PrinterTest

Thank you for your time!

1 Answer

Actually, I think I just got it! Maybe a quirk between versions of IntelliJ, but...

When importing the project, the default import options contain:

  • [ ] Use Auto Import (default for me: OFF)
  • [ ] Create directories for empty content roots automatically (default for me: OFF)
  • [ ] Create separate module per set (default for me: ON)

When i imported the file with ON, ON, OFF above, I no longer encountered the issue. I know it's not a very technical solution, but trial and error won out! Testing multiple configurations points to "Create separate module per set" being the root of the issue; with that disabled, the issue is no longer present.

Steps for IntelliJ:

  1. Download project from treehouse quiz
  2. Unzip project
  3. Within IntelliJ, select File > Open > select your project folder
  4. The Import Project from Gradle pane should pop up without manual selection, then within the pane:
  • DISABLE "Create separate module per source set" (critical) ***from my tests, this is the primary source of the issue
  • Enable "Use auto-import" (optional)
  • Enable "Create directories for empty content roots automatically" (optional)
  • Hit OK and you should be able to build your project as provided without exceptions
Daniel Silva
Daniel Silva
11,209 Points

Can you explain a little more in detail what you did? I'm having the same issue. It's driving me crazy. I'm on the auto import settings but I don't see any of the options you mentioned above.

UPDATE, I found what you meant "Import Gradle Project" however even after I did that I'm still getting that error with printer test class.

Hey Daniel, do the steps to reproduce help?