This is displayed in my Terminal Window application.
HTML:
Exception in thread "main" java.lang.NoClassDefFoundError: Add2Integers/java
Caused by: java.lang.ClassNotFoundException: Add2Integers.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
There are a few points that I need to make before answering the original question.
1. This code is based on a package designed to help ease the learning curve of Java. The problem with this approach is that most of us don't use that library (ConsoleProgram is actually acm.program. ConsoleProgram which I have never seen before)
2. The compiler (javac) is used to convert a .java file into a .class file. This is done before the program executes. I'm guessing you are using an IDE such as Eclipse or NetBeans which compiles automatically for you.
3. The stack trace is actually from running the program, not compiling it. It does compile, it just doesn't run correctly.
There are two hints as to what the problem is. The first is the "Exception in thread "main" java.lang.NoClassDefFoundError: Add2Integers/java" message most notably the "Add2Integers/java" on the end. The next is the very next line "Caused by: java.lang.ClassNotFoundException: Add2Integers.java" Remember, in Java the full class name includes the package with periods between the names. You can also put a class inside of a class. For example, if you added "class Foobar" inside of Add2Integers the it would be "Add2Integers.Foobar".
Now look at the second line of the stack trace. Notice that it says it cannot find "Add2Integers.java"? Somewhere, you told it to run with Add2Integers.java and it is looking for "class java" inside of Add2Integers. To fix it, change the way you start the program with just Add2Integers instead of Add2Integers.java.