I am able to compile Beverage.java. However, I get error when I run Beverage.java
Exception in thread "main" java.lang.NoClassDefFoundError: Beverage (wrong name: cert/Beverage)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:698)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
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)
When I compile Tea.java, I get errors
Tea.java:2: package cert does not exist
import cert.Beverage;
^
Tea.java:4: cannot find symbol
symbol: class Beverage
class Tea extends Beverage { }
^
2 errors
Is this something that will be covered later in Sierra/Bates book. From what I understand, Tea.java should not compile because Beverage is not public. However, I am unable to test this out because I cannot even run Beverage.java.
If your classes are in packages, then they need to be in specific directories that correspond to the package hierarchy. This is probably covered somewhere in the book, but in case it's not, start reading at http://java.sun.com/docs/books/tutorial/java/package/index.html, particularly "Managing Source and Class Files".