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 Objects Meet Objects Constructors

Brian Madden
Brian Madden
474 Points

[SOLVED] bash: Example: command not found error message

I keep getting the following error message listed in the title when trying to compile the following constructor codes. Would i be able to get some insight? my codes are listed below for each file.

here is my example.java code:

public class Example {

  public static void main(String[] args) {
    // Your amazing code goes here...
    System.out.println("We are making a new PEZ Dispenser");
    PezDispenser dispenser = new PezDispenser("Donatello");
    System.out.printf("The dispenser is %s %n", 
                      dispenser.getCharacterName()
                     );
  }

}

here is my PezDispenser.java code:

class PezDispenser {

  private String characterName;

  public PezDispenser(String characterName) 
  {
    this.characterName = characterName;
  }

  //String.contains
  // public boolean contains(String matchingText)

  public String getCharacterName() 
  {
    return characterName;
  }

}
Brian Madden
Brian Madden
474 Points

solved my own problem fellas. Dyslexia decided to kick in haha. when running the program i did clear && javac Example.java && Example java instead of clear && javac Example.java && java Example