- Forward


Applications
in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

What Are They?
Back SMYC Forward
  • Program (in an Object-Oriented Language):
    • A group of cooperating classes with a well-defined entry point (i.e., a method that should be executed first)and, perhaps, a re-entry point and/or an exit point.
  • Application:
    • Runs under the operating system
    • Entry point is main()
    • Top-level container is usually a JFrame (or Frame)
Applications in Java
Back SMYC Forward
  • The "main class" can extends anything but often just extends Object
  • An application can interact with its "environment" using the System class
The Application Lifecycle in Java
Back SMYC Forward
  • When an application is started the main() method is executed in a non-daemon thread called the main thread.
  • A single-threaded application terminates when the System.exit() method is called, in response to a platform-specific event such as a SIGINT or a Ctrl-C, or when the main thread "drops out of" the main() method.
  • A multi-threaded application terminates when the System.exit() method is called, in response to a platform specific event, or when all non-daemon threads have died.
Starting Applications
Back SMYC Forward
  • The JVM can be started and informed of what application to start by typing:
    java application
    at the command line
  • Applications in (executable) JAR files can be started by clicking/double-clicking on the JAR file.
  • The CLASSPATH environment variable is used to identify the location of packages.
  • To pass parameters to an application at the command line, include them after the application.
There's Always More to Learn
Back -