2.4 Going Forward
Now you've explored the basic foundations of the Mac OS X Java
platform. The
If you are interested in desktop (also known as client-side) development, start with Chapter 4 and Chapter 5, which cover GUI applications and Apple extensions. From there, you may want to move on to standalone applications in Chapter 7. Then you might benefit from exploring other Apple technologies, such as Speech, QuickTime, and Spelling. There is also a lot to be said about Mac OS X's enterprise support for Java. If you are primarily interested in web-delivered client applications, look at Chapter 8. If you want to learn more about web application development, concentrate on Chapter 12 through Chapter 15.
No matter what
|
Chapter 3. Java ToolsOne of the nicest things about Mac OS X is its very broad range of tools. The Classic Mac OS platform had many software development tools, of which the most popular and flexible was Metrowerks CodeWarrior. The release of Mac OS X, however, has broadened the range of available tools tremendously, and a large set of Java- and Unix-based tools is now available. Mac OS X also ships with Project Builder, an integrated desktop environment for programming in several languages, including Java. It's worth taking the time to review the various tools. If you're an old emacs or vi hand, you'll be able to access those tools (just fire up the Terminal). Even if you're an emacs or vi addict, you still might want to browse through the tools just to get an idea of what folks are talking about. |
3.1 Terminal
The revolutionary thing about Mac OS X for a developer is a
single, boring window with a blinking cursor. Double-click on the
main icon for your computer on the desktop, navigate into the
Applications
directory, and then into
Utilities
. Inside this folder, you'll see a Terminal
icon. Double-click on this icon to
You'll then see a "Welcome to Darwin!" message and a localhost prompt. The shell is the Unix standard tcsh , which stands for "Tenex csh." csh was the default shell for BSD Unix through the 1980s (and Mac OS X is based on BSD Unix). tcsh is an upward-compatible enhancement of csh , which includes "command completion" borrowed from an early 1970s experimental operating system called Tenex.
3.1.1 Basic Terminal CommandsLearning to use the Terminal is far beyond the scope of this text, but a few basic commands are required for basic system navigation. These common commands are listed here:
When you first launch the Terminal, you are presented with a blinking cursor. Type pwd and press return. You will have started in your specific user's home directory (for example, my username is wiverson , so my Terminal starts in /Users/wiverson ). Now type ls . This will print a directory listing to your screen. Then type cd Desktop and hit return. Type pwd , and you will see that you have changed your current working directory to /Users/[username]/Desktop . Type ls and you will see files on your Desktop. Type cd ~ (on many English QWERTY keyboards, this is the shifted version of the key to the left of the number "1"). This command will return you to the home directory. 3.1.2 A Simple Java ClassNow enter pico HelloWorld.java . This command launches the pico application, a simple terminal-based text editor. The editor is now ready to work on a file called HelloWorld.java . Enter the text shown in Example 3-1. Example 3-1. A simple HelloWorld class
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Press Control-O to save the file (or "WriteOut", as the command is labeled). Then use Control-X to quit pico .
Type
javac
*.java
at the command line and hit
return. It may take a moment, but
Once the file compiles, type java HelloWorld from the command line (don't add the .class extension). It should now print out "Hello World!" You can take this HelloWorld.class file, and any computer that has a Java Virtual Machine should be able to run it.
This section has reviewed a very basic set of operations. If you
need more information,
3.1.3 Environment
|
|
A common bugaboo is the
CLASSPATH
environment variable,
a source of much Java heartache. Whenever possible, I recommend