Wiley Publishing - Java and Mac OS X.pdf
(
22997 KB
)
Pobierz
Java
®
and
®
X
Mac OS
T. Gene Davis
Java® and Mac OS® X
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-52511-1
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, 201-748-6011,
fax 201-748-6008, or online at http://www.wiley.com/go/permissions.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO
REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE
CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR
EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN
MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT
THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL
SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL
PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR
DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS
WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT
THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY
PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET
WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK
WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services or to obtain technical support, please contact our
Customer Care Department within the U.S. at (877) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.
Library of Congress Control Number: 2010923561
Trademarks:
Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its
affiliates, in the United States and other countries, and may not be used without written permission. Java is a
registered trademark of Sun Microsystems, Inc. Mac OS is a registered trademark of Apple, Inc. All other trademarks
are the property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor
mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xv
Contents
Part I: Getting Started ......................................................................... 1
Chapter 1: Programming Java for OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Reviewing Apple Java History............................................................................................................................................3
Installing the OS X Developer Tools ...................................................................................................................................5
Exploring the Apple Developer Connection .......................................................................................................................8
Exploring Reference Library topics........................................................................................................................8
Finding developer articles ..................................................................................................................................10
Obtaining software seeds ...................................................................................................................................11
Benefiting from membership .............................................................................................................................12
Avoiding Deprecated Java Cocoa Libraries .......................................................................................................................13
Understanding the history of Java Cocoa libraries ..............................................................................................13
Reviewing deprecated libraries ..........................................................................................................................14
Understanding why Java Cocoa libraries were redundant ..................................................................................16
Exploring Available IDEs ..................................................................................................................................................17
Developing with Xcode.......................................................................................................................................17
Developing with Eclipse .....................................................................................................................................19
Developing with NetBeans .................................................................................................................................21
Summary .........................................................................................................................................................................22
Chapter 2: Introducing the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Configuring the JVMs ......................................................................................................................................................23
Identifying JVM locations ...................................................................................................................................25
Setting Java Preferences with “Java Preferences” ..............................................................................................30
Adding Libraries ..............................................................................................................................................................32
Exploring library locations ..................................................................................................................................33
Including JARs and native libraries .....................................................................................................................34
Creating custom libraries....................................................................................................................................35
Finding Environment Variables .......................................................................................................................................37
Setting JAVA_HOME...........................................................................................................................................37
Exploring dot files and dot folders ......................................................................................................................39
Using system-wide properties ............................................................................................................................41
Accessing OS X environment...............................................................................................................................44
Summary .........................................................................................................................................................................44
ix
x
Contents
Chapter 3: Understanding Xcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Exploring Project Templates ............................................................................................................................................45
Creating Java Console Application Projects.........................................................................................................46
Creating Java application projects ......................................................................................................................55
Creating Java Applet projects .............................................................................................................................63
Using JNI Library projects ...................................................................................................................................70
Highlighting Xcode Features ...........................................................................................................................................74
Browsing the welcome screen ............................................................................................................................74
Setting up a source code repository ....................................................................................................................76
Modifying the View ............................................................................................................................................80
Watching tasks with the Activity window ..........................................................................................................84
Architecting with Xcode .....................................................................................................................................85
Changing Xcode preferences ..............................................................................................................................89
Inserting Java Code using macros .......................................................................................................................93
Using Organizer ...............................................................................................................................................................94
Managing projects..............................................................................................................................................95
Running projects ................................................................................................................................................96
Creating Java projects from Organizer templates ...............................................................................................96
Summary .........................................................................................................................................................................98
Chapter 4: Building Basic Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Building Xcode Projects ...................................................................................................................................................99
Understanding the Xcode Build Process............................................................................................................100
Running Xcode projects ....................................................................................................................................104
Debugging Xcode projects ................................................................................................................................106
Writing Ant Build Files...................................................................................................................................................108
Understanding Ant ...........................................................................................................................................109
Creating a basic Ant build file ...........................................................................................................................111
Defining multiple targets .................................................................................................................................116
Learning properties and advanced elements ....................................................................................................123
Configuring Ant options ...................................................................................................................................127
Compiling from the Terminal ........................................................................................................................................129
Reviewing the Java command-line tools ..........................................................................................................129
Configuring Javac .............................................................................................................................................131
Scripting builds ................................................................................................................................................135
Summary .......................................................................................................................................................................141
Chapter 5: Deploying Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143
Learning Application Bundle Basics ...............................................................................................................................143
Contrasting bundles and packages ...................................................................................................................144
Exploring application packages ........................................................................................................................144
Creating Icons................................................................................................................................................................148
Understanding Human Interface Guidelines for icons.......................................................................................149
Creating icons with Photoshop .........................................................................................................................150
Contents
xi
Creating icons with Illustrator ..........................................................................................................................161
Assembling the icon .........................................................................................................................................167
Creating Packages with Jar Bundler...............................................................................................................................169
Understanding Jar Bundler options ..................................................................................................................170
Demonstrating Jar Bundler...............................................................................................................................174
Producing Installations..................................................................................................................................................175
Understanding OS X installations .....................................................................................................................176
Creating DMGs for drag-and-drop installations ................................................................................................176
Creating PKG bundles .......................................................................................................................................178
Creating izPack installations .............................................................................................................................180
Summary .......................................................................................................................................................................181
Part II: Bringing Guidelines, APIs, and Languages Together ......... 183
Chapter 6: Porting and Designing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185
Exploring Mac OS X Structure.........................................................................................................................................185
Reviewing the architectural layers ...................................................................................................................186
Benefiting from OS X frameworks.....................................................................................................................187
Using Darwin .................................................................................................................................................................188
Examining the BSD foundations of OS X ...........................................................................................................189
Using Darwin tools ...........................................................................................................................................190
Exploring the Darwin libraries ..........................................................................................................................194
Scripting Java in the shell ................................................................................................................................195
Learning the Human Interface Guidelines .....................................................................................................................197
Providing an OS X experience ...........................................................................................................................198
Designing the user interface .............................................................................................................................198
Updating software............................................................................................................................................200
Integrating OS X technologies ..........................................................................................................................210
Summary .......................................................................................................................................................................211
Chapter 7: Integrating Windows, Menus, and Dialog Boxes . . . . . . . . . . . . . .213
Learning com.apple.eio.FileManager ............................................................................................................................214
Finding application bundles .............................................................................................................................214
Locating bundle resources ................................................................................................................................214
Getting and setting file types and creators .......................................................................................................215
Investigating com.apple.eawt Classes ...........................................................................................................................218
Manipulating the Dock .....................................................................................................................................219
Opening the Help Viewer..................................................................................................................................222
Handling About, Preferences, and Quit.............................................................................................................229
Persisting Preferences .........................................................................................................................234
Creating Human Interface compliant About boxes ..............................................................................236
Finding your mouse location ............................................................................................................................237
Summary .......................................................................................................................................................................239
Plik z chomika:
yok2
Inne pliki z tego folderu:
Morgan Kaufmann - Java - Practical Guide for Programmers.pdf
(2363 KB)
MIT Press - Java Precisely.pdf
(874 KB)
Morgan Kaufmann - Programming Cameras and Pan-Tilts with DirectX and Java.pdf
(3996 KB)
Morgan Kaufmann - TCP IP Sockets in Java Practical Guide for Programmers, 2e.pdf
(1055 KB)
Oracle Press - Java The Complete Reference Ninth Edition[A4].pdf
(39311 KB)
Inne foldery tego chomika:
Zgłoś jeśli
naruszono regulamin