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 Annotations Using Java's Built-In Annotations Using the Directory and Xlint Command Line Options

David Sampimon
David Sampimon
12,026 Points

after compiling only the Main.class can be found in the out/com/teamtreehouse/override folder

I am following along the video in the workspace, however as we get to the step where we change the output directory for the javac comand, I only end up with a 'Main.class' in the output folder and I am missing the 'Cheese.class'. In the video you can see that both class files are created in the output folder. Why doesnt javac compile Cheese.java?

When I compiled using the default output directory (the same directory as where the Main.java and Cheese.jave are located) I ended up with both class files correctly.

I used the below command in the console

treehouse:~/workspace$ javac -Xlint -d out -cp src src/com/teamtreehouse/override/Main
Picked up JAVA_TOOL_OPTIONS: -Xmx128m                                                 
Picked up _JAVA_OPTIONS: -Xmx128m  

and this is the code of both classes

package com.teamtreehouse.override;

public class Main {
    public static void main(String[] args) {
        Cheese myCheese = new Cheese();


package  com.teamtreehouse.override;

public class Cheese {
  public String toString() {
   return "String cheese!"; 


1 Answer

Zac Mazza
Zac Mazza
5,867 Points

Do you only have one file? If so, you'll only have one class. Each .java file is compiled into it's own .class file. The only time you would see two .class files is if you separated Main and Cheese into two separate files.