Finding Your Project Files

The Java code that you typed to make the Greeter class is called source code. It is human-readable and is stored as a text file with the extension ".java". In order for your code to be run, it is translated into executable instructions by a tool called a compiler. Eclipse normally runs the compiler automatically each time you save a file. For Java code, the executable files are called class files and have the extension ".class".

In Java, the name of the file always matches the name of the public class it contains, so our source file is called "Greeter.java". In addition, if the class is within a package, the file has to be located in a directory matching the package name. (Packages can also be nested, corresponding to a nested sequence of directories.)

By default, Eclipse puts our source files in a directory called src and puts the corresponding class files in a directory called bin. Both of these are located within the project directory in the workspace. The name of the project directory matches the name of the project you created in Eclipse. Putting this all together, for example, if your workspace is U:\cs227\workspace, we should be able to find two files:

U:\cs227\workspace\project1\src\lab1\Greeter.java

U:\cs227\workspace\project1\bin\lab1\Greeter.class

Using File Explorer (or the OS X Finder), find these two files.

Making file extensions visible

Most filenames actually have an extension consisting of a period followed by several letters, such as .class or .java. For some bizarre reason, the default for File Explorer is to hide that part of the file name. In programming we frequently are in a situation where there are two or more files whose names only differ in the extension. In this course it will be crucial for you to be able to distinguish between them, e.g., to distinguish .java files and .class files.

Windows

  1. In File Explorer, click on the "File" tab.
  2. In the drop-down menu, select "Change folder and search options".
    Changing folder view options
  3. In the Folder Options dialog that comes up, click on the "View" tab.
  4. UN-check the option "Hide extensions for known file types".
    Changing folder view options
  5. Click "Apply to Folders" and then "OK". (If "Apply to Folders" button is disabled, just click OK. )

OS X

Go to Finder -> Preferences -> Advanced and check the box "Show all filename extensions". Changing folder view options

Checkpoint 2

  1. Run your Greeter program for the TA.
  2. Show the TA that you can delete the Package Explorer and then bring it back again.
  3. Show the TA the two files Greeter.java and Greeter.class in File Explorer or Finder with the file extensions visible.