Java programs can be used in two ways
:
-
Stand alone EXEs
-
Applets which operate only within a browser
The Java compiler creates a file that contains Java bytecodes, which in turn are interpreted
by the interpreter on each specific Java platform.
Java source code is saved in a .java text file. The compiled bytecode is saved to a .
class
binary file.
Source code consists entirely of classes. Program starts in a
class
which has a
'main'
method.
Source code lines end in semi
-
colon
class
MyClass
{
public
statis
void
Main(String[] arguments)
{
'main statements go here
}
}
myProgram.java (source code)
-->
myProgram.
class
(bytecode)
It is the .
class
file that is interpreted by the Java interpreter on a specific platform.
Java Platform consists of
:
-
Java Virtual Machine (interpreter)
-
Java API
Java API are grouped into
"packages"
which contain related classes and interfaces.
A Java applet is a Java program which adheres to specific conventions that allow it
to run within a Java
-
enabled browser. Java applets can also be viewed in a free
program called appletviewer.
JDK
-
Java Development Kit from Sun
-
Java compiler
-
a few applets
-
stand
-
alone AppletViewer