Class File Creation

Although the details of each step may differ depending on whether you are using a Java development tool, the steps involved in creating your own class generally include the following steps:

  1. Define your class.

    Write the Java code that defines your class.

  2. Name and save your class.

    Save your class declaration (Java code) in a file with the extension .java. Make certain the name of the file is the same as the name of the class and that the case of both names is identical.

    For example, a class called Utility should be saved in a file called Utility.java.

  3. Compile your class.

    This step turns your class declaration containing Java code into a new, separate file containing byte code. The name of the new file is the same as the Java code file, but has an extension of .class. You can run a compiled Java class in a Java Runtime Environment, regardless of the platform you compiled it on or the operating system of the runtime environment.