CIS 26
Object-Oriented Programming
Lecture 01-2 - Introduction To Java Programs
Applications and Applets
- Applications
- Standalone programs
- Run from command line
- Console- or graphic- (window) based
- Applets
- Program running in the context of a Web page
- Executed (as a client) within a browser
Applications
- A simple, sample application
- To compile:
javac HelloWorld.java
javac
is the compiler
- Note the
.java
extension must be specified
- A
.class
file is created (in this case HelloWorld.class
--
it's the name of the class followed by the .class
extension).
- To execute:
java HelloWorld
java
is the interpreter
- The argument os the name of the class-- the
.class
extension is
not specified.
- Some items to note
- In general, use the same name for the source file as for its contained class
- Note the
main
method (function)
- This is the entry point for the application
- All Java applications must have a main method
- The class passed as the argument to the Java interpreter must have a main method
System.out
is the standard output (console)
- The array of
String
parameter to main
contain the command-line arguments
Applets