Pages

The Anatomy of a Java Program

GENTLE JAVA READER/WRITER: Understanding the process of composing, compiling and executing a Java program will make you a better debugger and a more flexible coder. This page briefly describes important pieces of that process; however, it glosses over or omits sundry details. For example, sometimes source code files produced by an editor are not successfully translated into .class files by the javac compiler. When this happens, you have to figure out what went wrong and fix the problem. Sometimes steps may be hidden from view. If you edit a Java program on a website like compilejava.net, for example, you might not realize that .java and .class files are being created on a server somewhere — but they are! Details may also be lurking behind a curtain if you use a Java integrated development environment (IDE) to work with programs locally, as opposed to on a remote computer.

Foobar FUBAR
Let textEditor (or IDE) ← YOU_PICK
Let sourceCodeclass Foobar {}
  1. Edit. textEditor ⇐ sourceCode
  2. Save. textEditor ⇒ Foobar.java
  3. Compile.
    javac Foobar.java ⇒ Foobar.class
  4. Execute.
    java Foobar ⇒ Error:
    Main method not found

A Procedure

  1. A person’s brain creates ideas;
  2. Ideas are converted to human output;
  3. Human output becomes computer input;
  4. Computer input goes to a source code editor;
  5. A source code editor produces .java files;
  6. The .java files are read by the javac compiler;
  7. The javac compiler produces .class files;
  8. The .class files are read by the java loader;
  9. The java loader produces program output;
  10. Program output becomes human input;
  11. Human input goes to a person’s brain;
  12. A person’s brain interprets the input; repeat.

Dem Bones

  1. Toe bone connected to the foot bone
  2. Foot bone connected to the heel bone
  3. Heel bone connected to the ankle bone
  4. Ankle bone connected to the shin bone
  5. Shin bone connected to the knee bone
  6. Knee bone connected to the thigh bone
  7. Thigh bone connected to the hip bone
  8. Hip bone connected to the back bone
  9. Back bone connected to the shoulder bone
  10. Shoulder bone connected to the neck bone
  11. Neck bone connected to the head bone
  12. Now hear the word of the Lord.

JDK: The Kit Behind the Curtain

Java was originally developed by James Gosling at Sun Microsystems, which was subsequently acquired by Oracle Corporation.

“The” Java Development Kit (JDK) is an implementation of the Java Platform Standard Edition, Java Platform Enterprise Edition, or Java Platform Micro Edition platforms released by Oracle Corporation in the form of a binary product aimed at Java developers on Solaris, Linux, macOS or Windows. JDK packages can be downloaded from Oracle. Besides a text editor, the necessary permissions, and perhaps a command-line interface, a JDK is all you need to create and execute Java programs. It’s often the kit behind the curtain.

☁ ☁ ☁

compilejava.net

tutorialspoint.com/compile_java_online.php

browxy.com

☁ ☁ ☁

Before proceeding much further, you really ought to know how to create, update, and keep track of text files stored in folders or directories—either on your local computer, on a server that your computer is configured to communicate with, or in some place that you know how to get to in the cloud. Being able to type efficiently and accurately is also an important skill to have. Remediation of questionable text editing or file management skills is strongly encouraged.

⚽ ⚽ ⚽

Java Program Anatomy Exercises

⚾ ⚾ ⚾
“Gentle reader, may you never feel what I then felt! May your eyes never shed such stormy, scalding, heart-wrung tears as poured from mine. May you never appeal to Heaven in prayers so hopeless and so agised as in that hour left my lips: for never may you, like me, dread to be the instrument of evil to what you wholly love.”

— Charlotte Brontë, Jane Eyre