1

I'm learning how to implement interfaces following a YouTube video. He runs the code that I've posted following and I run the same code. His compiles and prints while mine gives me the error code:

Machine startedException in thread "main" java.lang.NoClassDefFoundError: 
 Person
at App.main(App.java:9)
 Caused by: java.lang.ClassNotFoundException: Person
at java.base...(etc.)

is this due to me running jGrasp while he runs Eclipse? The code of the tutorial program follows:

public class App{
  public static void main(String[] args){

 Machine mach1 = new Machine();
    mach1.start();

 Person person1 = new Person("Bob");
    person1.greet();

 Info info1 = new Machine();
    info1.showInfo();

 Info info2 = person1;
    info2.showInfo();
 }//end of main class 
}//end of App class
public class Machine implements Info{
  private int id = 7;

  public void start(){
    System.out.print("Machine started");
  }
  public void showInfo(){
   System.out.println("Machine id is " + id);
  }
}//end of machine class 
public class Person implements Info{
  private String name;

  public Person(String name){
    this.name = name;
  }
  public void greet(){
    System.out.println("Hello there");
  }
  public void Info(){
    System.out.print("Person name is " + name);
  }
}//end of person class
public interface Info{
  public void showInfo();
}//end of interface
charley
  • 11
  • 1
  • Either put all classes/interfaces in separate files (`App.java`, `Machine.java`, `Person.java` and `Info.java`) or everything in `App.java` without `public` before `class Machine`, `class Person` and `interface Info`. In the class `Person` rename the method `Info()` (according to the implementing interface) to `showInfo()`. – howlger Jan 29 '18 at 07:39

0 Answers0