Introduction to java programming language

$ javac
$ java -cp . HelloWorld

$ javac -d .
$ java -cp . com.mynotes.examples.SimpleExample

With the java command, the -cp (class path) option is used to designate where the command should seek out the specified class(es). In this Example. is used to designate that the root directory for the classes is the current local directory.

Note the use of the -d parameter with the javac command, which tells the compiler that the destination of the compiled class (SimpleExample) and its directory structure’s root is the local directory in which the Java file is located. What this means is that a directory named com will be created. Within this com directory, an examples directory is placed, and within examples, SimpleExample.class is generated (see Figure 2-1). This

Package names are all lowercase.

Packages in the Java language begin with “java” or “javax.”

Generally, companies use their Internet domain in reverse order (so a company like would become com.oreilly, would become org.nonprofit, etc.). If the domain contains some special characters (nonalphanumeric) or conflicts with a reserved Java keyword, it is either not used or an underscore (_) is used instead.

In Java, what’s the difference between public, default, protected, and private?

Public are accessible from everywhere. Protected are accessible by the classes of the same package and the subclasses residing in any package. Default are accessible by the classes of the same package. private are accessible within the same class only.

When should I use “this” in a class?

Understanding constructors