Download Chapter Three - Introduction to Java

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
George Blank
University Lecturer
CS 602
Java and the Web
Object Oriented Software Development
Using Java
Chapter 3
Chapter Overview
• Chapter 3 is an introduction to the Java language. Java is
available in various subsets of the language so that different
editions can serve uses ranging from supporting large
enterprise application distributed over many systems to
small embedded controllers running devices such as a home
thermostat and even smart cards.
• Understand the features of the language, the various
editions of Java, the run-time architecture, applications and
applets.
Editions for this course
• This course is based on the Java 2 Standard
Edition (J2SE), version 1.7 or later. If you
choose to do a project from chapter 12, you
may wish to use the Java 2 Enterprise Edition
(J2EE) instead. You should be able to give a
short explanation of the difference between
the various editions of Java.
Run-time Architecture
• The text has a good, concise basic
explanation of the Java run-time architecture
(Section 3.2). It is important to understand
this material.
• I have discovered that many employers have
been very concerned with security, so study
and understand the supplemental lecture on
Java Security as well.
Getting Started
• Most common problems in Java development come
from setting up the environment, especially the
classpath.
Hello From Venus Code
/*
* Copyright (c) 1999-2002, Xiaoping Jia. All Rights Reserved.
*/
import java.awt.*;
import java.applet.Applet;
public class HelloFromVenus extends Applet {
public void paint(Graphics g) {
Dimension d = getSize();
g.setColor(Color.black);
g.fillRect(0,0,d.width,d.height);
g.setFont(new Font("Helvetica", Font.BOLD, 24));
g.setColor(new Color(255, 215, 0)); // gold color
g.drawString("Hello From Venus!", 40, 25);
g.drawImage(getImage(getCodeBase(), "Venus.gif"),
20, 60, this);
}
}
Programming Problems
• Be familiar with the common problems and solutions
on page 72 of the text.
• The primary means of technical support in this class
will be self help from your classmates in the
Technical Support thread on Moodle. You must learn
to describe your problem well. You will also be
expected to become familiar with the Java
Documentation.
Most common problem in Java Setting Environment
• You can set the class path for Java from the
operating system with
• set classpath={your class location}
• In most Windows systems, you can search
Help for “environment variables” to find out
how to set your classpath.
Other common problems
•
The command to compile is
javac {yourfilename}.java
•
•
On AFS, you cannot connect to afs.njit.edu. You
must specify a specific host between
afsaccess1.njit.edu and
afsacess4.njit.edu.
Typing java –version will tell you what version
of Java is currently active on your system. If you
have multiple versions installed, you might have
problems.
Works on Windows, not UCS
• If your program works in Windows, but not on Unix or
OSX:
• Programs loaded over a network cannot access files and
libraries on the local machine without policy files, signed
jars, or security managers.
• Windows allows spaces in file names. Unix requires them
to be filled. (Use %20 in HTML)
• Unix requires shorter filenames.
• Unix and Java are case sensitive, Windows ignores case,
so MyFile.Class = myfile.class.
• Windows allows \ in pathnames. Unix requires /.
• If you neet to run and applet, Appletviewer is less
restrictive than browsers.
Some useful links at NJIT
• This is the main help site:
http://ist.njit.edu/
• If you use a Virtual Private Network get
software and installation instructions here:
http://ist.njit.edu/vpn/
Bibliography
• http://java.com/en/ Be especially familiar with
the documentation accessed from the
Reference menu on the left side of this page.
This is also where you can download Java.
• Jia, Xiaoping, Object Oriented Software
Development Using Java. Addison Wesley,
2003