You can choose from essentially two different programming environments
for Java:
- Manual - with your favorite
text editor (see below) create the Java
source code files (*.java)
and then use the command line tools in the Java Software Development
Kit (SDK). The SDK is provided by Sun for several platforms
and includes a number of tools, the most important of which are:
- javac
- compiles Java source code files (e.g. Test.java)
to bytecode files (e.g. Test.class)
*
- java
- runs Java application programs (i.e. implements the JVM for
the Java programs.)
- appletviewer
- tests applets independently of a browser.
- Integrated Development
Environment (IDE) - graphical
user interface programming environments (often called GUI Builders)
are elaborate, programs that allow you to interactively build
graphical interfaces, edit the code, execute and run the applets
and applications all within the IDE system. Example Java IDEs
include:
- NetBeans
- free, open source Java IDE - can be installed along with
the SDK.
- Borland
JBuilder - proprietary but the personal version is free
with registration
Note:
During this course we recommend the manual approach
so that you will learn the details of the Java graphics system.
While it is fine to use the editor in the GUI Builder (see below),
you should write all of the code yourself rather than using the
interactive window building tools. Otherwise, the GUI builder
will do most of the work for you and you will learn very little.
Later when you begin developing your own programs with elaborate
graphical interfaces, you probably will want to use the a GUI builder.
However, even then you will occasionally want to modify the graphics
code by hand to debug a problem, for example, or tweak the look
of a window layout. So you need to understand graphic programming
well to do this.
Other suggestions:
- Source Code Editors:
For editing your programs, we recommend a language sensitive editor
that color codes the Java text. Keywords, strings and other items
will be highlighted. This helps to avoid simple spelling mistakes
and assists debugging.
Examples include:
- JEdit -
open source program written in Java
- vim - a version
of the Unix vi editor. Available for Unix & MS-Windows
- Applet Tools: applets are
intended primarily to run in browsers. However, It is usually
more convenient to use the appletviewer
program, which comes with the SDK, during debugging and tuning
of your applets. It is a command line program that is specialized
for running applets. It only needs an HTML page with the applet
tag for the particular applet of interest.
Once your applets work satisfactorily with appletviewer,
you can examine how they appear in the browser.
With the older JVMs that came installed in the browsers, it could
be difficult to force the browser to load a new class file rather
than use the old one in the cache. With Sun's Java
Plug-in, which should have been installed into your browsers
when you installed the SDK and is also available for downloading
from www.java.com,
the console window allows for various commands to the JVM including
the "x" command that clears the cache.
*
javac Target
Option
The javac
compiler includes the option "-target"
to specify that the class file be compatible with a particular JVM
for an earlier version of Java. For example,
>
javac -target 1.1 HelloWorld.java
will insure that the class file will run in Java 1.1
virtual machines.
Latest update: Oct.10.2004
|