Академический Документы
Профессиональный Документы
Культура Документы
1-1
Save your files on AFS server. Use SSH to connect or H:
drive in the lab.
1-2
• Java SE: This kit is necessary for developing all applications, except
those designed for consumer devices. Java SE comes bundled with the
compiler, a runtime environment, and core API.
• Java Platform Enterprise Edition (Java EE): This packages includes an
application server, web server, J2EE APIs, support for Enterprise
JavaBeans, Java Servlets API, and JavaServer Pages (JSP) technology.
Use J2EE with the Java SE.
• Java Platform Micro Edition (Java ME): If you are interested in
developing programs for Palm Pilots, screen phones, and other
consumer devices, this kit provides tools for compiling, deployment
and device configuration, and APIs that are specialized for each type
of device.
• JavaFX Script Technology is a highly productive scripting language
that enables content developers to create rich media and content for
deployment on Java environments.
1-3
• The development kits include the APIs necessary to whatever type of
applications you develop in the Java programming language.
• Java APIs are libraries of compiled code let you add ready-made and
customizable functionality to your programs to save coding time.
• Java programs are executed within a program called the JVM.
• Rather than running directly on the native operating system, the
program is interpreted by the JVM for the native operating system.
• This is key to making your programs portable from one platform to
another. In other words, you can develop your programs on a Solaris,
Linux, Macintosh, or Windows, then run it on another server or
platform.
1-4
• Once you have the development kits you need, you
are ready to begin writing code in the Java
programming language.
• Programs are written in three basic flavors: applets,
applications, and servlets/JSP pages.
• Applets run in the JVM built into a web browser;
applications run in the JVM installed on a computer
system; and servlets/JSP run in the JVM installed
on a web server.
1-5
Each release of the Java 2 SDK,
Standard Edition contains:
• Java Compiler
• Java Virtual Machine*
• Java Class Libraries
• Java AppletViewer
• Java Debugger and other tools
• Documentation (in a separate download
bundle)
1-6
1-6
Find the directory where it was
installed
• C:\Program Files\Java\jdk1.6.0_03\bin
1-7
1-7
PATH
1-8
1-8
Setting PATH on Windows XP
1-9
1-9
1-10
1-10
Compiling a Java program in
DOS
• Create the source program with a text editor (eg, DOS, Eclipse, jEdit,
TextPad, ...).
• DOS:
– Open a DOS command window and cd to the directory containing the source file.
– Compile the source program (Greeting.java in this example) with the following
DOS command:
javac Greeting.java
– This produces one or more ".class" files, which are the object (Java byte code)
form of Java programs. You can produce a ".exe" file from this, but that isn't
normally done.
– Run it with:
java Greeting
– This loads the Greeting.class file and all necessary classes.
1-11
1-11
Programs to use to compile java
applications: TextPad
TextPad:
• Minimum Requirements:
– IBM Compatible PC
– Microsoft Windows 95 (SP#1), NT 4 (SP#6), or later versions of Windows.
– COMCTL32.DLL 4.70 or later (can be downloaded from
http://support.microsoft.com/default.aspx?scid=KB;en-us;q186176).
– 3.5MB free disk space
1-12
1-12
Programs to use to compile java
applications: Eclipse
• Tutorial:
http://web.njit.edu/~soltis/cis114.htm
Exercise 1
num = 50;
while (num >= 0)
{
System.out.println (num);
Num – num + 1;
}
Answer 1:
• b.
Explanation: Java identifiers cannot start with
a number (so the answers in a, d and e are
illegal) and cannot include the “/” character,
so the answer in c is illegal.