When a Java class is stored in a package, you must include the path that corresponds to the package in the compile. To learn how to compile a Java class in a package and successfully run a Java program to test your work, follow these nine steps.
personpackage. Be sure to create this file in the
personpackagefolder. Type in the following Java statements:
packagestatement; this statement tells the compiler that the class is contained within the package (i.e., folder) named
personpackage. Therefore, the actual name of your Java class is
compile-packages-in-javafolder. Type in the following Java statements:
importstatement directs the compiler to resolve references to
compile-packages-in-javadirectory. Then type in the command to compile the Person source and hit Enter. Notice that you provided the path of the Java file. This path corresponds to the package name.
personpackage. Type in the command to run the Java runtime launcher and hit Enter. Observe the output showing the Person you instantiated using