SlideShare a Scribd company logo
DZone, Inc. | www.dzone.com 
tech facts at your fingertips 
CONTENTS INCLUDE: 
n Java Keywords 
n Standard Java Packages 
n Character Escape Sequences 
n Collections and Common Algorithms 
n Regular Expressions 
n JAR Files 
This refcard gives you an overview of key aspects of the Java 
language and cheat sheets on the core library (formatted 
output, collections, regular expressions, logging, properties) 
as well as the most commonly used tools (javac, java, jar). 
Core Java 
By Cay S. Horstmann 
Java Keywords, continued 
About CORE JAVA 
Java Keywords 
Core Java www.dzone.com Get More Refcardz! Visit refcardz.com 
Get More Refcardz 
(They’re free!) 
n Authoritative content 
n Designed for developers 
n Written by top experts 
n Latest tools & technologies 
n Hot tips & examples 
n Bonus content online 
n New issue every 1-2 weeks 
Subscribe Now for FREE! 
Refcardz.com 
→ 
Keyword Description Example 
abstract an abstract class or 
method 
abstract class Writable { 
public abstract void write(Writer out); 
public void save(String filename) { ... } 
} 
assert with assertions enabled, 
throws an error if 
condition not fulfilled 
assert param != null; 
Note: Run with -ea to enable assertions 
boolean the Boolean type with 
values true and false 
boolean more = false; 
break breaks out of a switch 
or loop 
while ((ch = in.next()) != -1) { 
if (ch == 'n') break; 
process(ch); 
} 
Note: Also see switch 
byte the 8-bit integer type byte b = -1; // Not the same as 0xFF 
Note: Be careful with bytes < 0 
case a case of a switch see switch 
catch the clause of a try block 
catching an exception 
see try 
char the Unicode character 
type 
char input = 'Q'; 
class defines a class type class Person { 
private String name; 
public Person(String aName) { 
name = aName; 
} 
public void print() { 
System.out.println(name); 
} 
} 
const not used 
continue continues at the end of 
a loop 
while ((ch = in.next()) != -1) { 
if (ch == ' ') continue; 
process(ch); 
} 
default the default clause of a 
switch 
see switch 
do the top of a do/while 
loop 
do { 
ch = in.next(); 
} while (ch == ' '); 
double the double-precision 
floating-number type 
double oneHalf = 0.5; 
else the else clause of an if 
statement 
see if 
enum an enumerated type enum Mood { SAD, HAPPY }; 
extends defines the parent class 
of a class 
class Student extends Person { 
private int id; 
public Student(String name, int anId) { ... } 
public void print() { ... } 
} 
final a constant, or a class or 
method that cannot be 
overridden 
public static final int DEFAULT_ID = 0; 
Keyword Description Example 
finally the part of a try block 
that is always executed 
see try 
float the single-precision 
floating-point type 
float oneHalf = 0.5F; 
for a loop type for (int i = 10; i >= 0; i--) 
System.out.println(i); 
for (String s : line.split("s+")) 
System.out.println(s); 
Note: In the “generalized” for loop, the expression 
after the : must be an array or an Iterable 
goto not used 
if a conditional statement if (input == 'Q') 
System.exit(0); 
else 
more = true; 
implements defines the interface(s) 
that a class implements 
class Student 
implements Printable { 
... 
} 
import imports a package import java.util.ArrayList; 
import com.dzone.refcardz.*; 
instanceof tests if an object is an 
instance of a class 
if (fred instanceof Student) 
value = ((Student) fred).getId(); 
Note: null instanceof T is always false 
int the 32-bit integer type int value = 0; 
interface an abstract type with 
methods that a class can 
implement 
interface Printable { 
void print(); 
} 
long the 64-bit long integer 
type 
long worldPopulation = 6710044745L; 
native a method implemented 
by the host system 
new allocates a new object 
or array 
Person fred = new Person("Fred"); 
null a null reference Person optional = null; 
package a package of classes package com.dzone.refcardz; 
private a feature that is 
accessible only by 
methods of this class 
see class 
protected a feature that is accessible 
only by methods of this 
class, its children, and 
other classes in the same 
package 
class Student { 
protected int id; 
... 
} 
#24
Core Java 
2 
Primitive types 
DZone, Inc. | www.dzone.com 
tech facts at your fingertips 
Java Keywords, continued 
Keyword Description Example 
public a feature that is 
accessible by methods 
of all classes 
see class 
return returns from a method int getId() { return id; } 
short the 16-bit integer type short skirtLength = 24; 
static a feature that is 
unique to its class, not 
to objects of its class 
public class WriteUtil { 
public static void write(Writable[] ws, 
String filename); 
public static final String DEFAULT_EXT = ".dat"; 
} 
strictfp Use strict rules 
for floating-point 
computations 
super invoke a superclass 
constructor or method 
public Student(String name, int anId) { 
super(name); id = anId; 
} 
public void print() { 
super.print(); 
System.out.println(id); 
} 
switch a selection statement switch (ch) { 
case 'Q': 
case 'q': 
more = false; break; 
case ' '; 
break; 
default: 
process(ch); break; 
} 
Note: If you omit a break, processing continues 
with the next case. 
synchronized a method or code 
block that is atomic to 
a thread 
public synchronized void addGrade(String gr) { 
grades.add(gr); 
} 
this the implicit argument 
of a method, or a 
constructor of this class 
public Student(String id) {this.id = id;} 
public Student() { this(""); } 
throw throws an exception if (param == null) 
throw new IllegalArgumentException(); 
throws the exceptions that a 
method can throw 
public void print() 
throws PrinterException, IOException 
transient marks data that should 
not be persistent 
class Student { 
private transient Data cachedData; 
... 
} 
try a block of code that 
traps exceptions 
try { 
try { 
fred.print(out); 
} catch (PrinterException ex) { 
ex.printStackTrace(); 
} 
} finally { 
out.close(); 
} 
void denotes a method 
that returns no value 
public void print() { ... } 
volatile ensures that a field is 
coherently accessed 
by multiple threads 
class Student { 
private volatile int nextId; 
... 
} 
while a loop while (in.hasNext()) 
process(in.next()); 
Operator Precedence 
Operators with the 
same precedence 
Notes 
[] . () (method call) Left to right 
! ~ ++ -- + (unary) – 
(unary) () (cast) new 
Right to left ~ flips each bit of a number 
* / % Left to right Be careful when using % with negative 
numbers. -a % b == -(a % b), but a 
% -b == a % b. For example, -7 % 4 
== -3, 7 % -4 == 3. 
+ - Left to right 
<< >> >>> Left to right >> is arithmetic shift (n >> 1 == n / 2 for 
positive and negative numbers), >>> is logical 
shift (adding 0 to the highest bits). The right 
hand side is reduced modulo 32 if the left hand 
side is an int or modulo 64 if the left hand side 
is a long. For example, 1 << 35 == 1 << 3. 
< <= > >= instanceof Left to right null instanceof T is always false 
== != Left to right Checks for identity. Use equals to check for 
structural equality. 
& Left to right Bitwise AND; no lazy evaluation with bool 
arguments 
^ Left to right Bitwise XOR 
| Left to right Bitwise OR; no lazy evaluation with bool 
arguments 
&& Left to right 
|| Left to right 
?: Right to left 
= += -= *= /= %= &= 
|= ^= <<= >>= >>>= 
Right to left 
Type Size Range Notes 
int 4 bytes –2,147,483,648 to 2,147,483, 647 
(just over 2 billion) 
The wrapper type is Integer. 
Use BigInteger for arbitrary 
precision integers. 
short 2 bytes –32,768 to 32,767 
long 8 bytes –9,223,372,036,854,775,808 to 
9,223,372,036,854,775,807 
Literals end with L (e.g. 1L). 
byte 1 byte –128 to 127 Note that the range is not 
0 ... 255. 
float 4 bytes approximately 
±3.40282347E+38F (6–7 
significant decimal digits) 
Literals end with F (e.g. 0.5F) 
double 8 bytes approximately 
±1.79769313486231570E+308 
(15 significant decimal digits) 
Use BigDecimal for arbitrary 
precision floating-point 
numbers. 
char 2 bytes u0000 to uFFFF The wrapper type is 
Character. Unicode 
characters > U+FFFF require 
two char values. 
boolean true or false 
Standard Java Packages 
java.applet Applets (Java programs that run inside a web page) 
java.awt Graphics and graphical user interfaces 
java.beans Support for JavaBeans components (classes with properties and 
event listeners) 
java.io Input and output 
java.lang Language support 
java.math Arbitrary-precision numbers 
java.net Networking 
java.nio “New” (memory-mapped) I/O 
java.rmi Remote method invocations 
java.security Security support 
java.sql Database support 
java.text Internationalized formatting of text and numbers 
java.util Utilities (including data structures, concurrency, regular expressions, 
and logging) 
Legal conversions between primitive types 
Dotted arrows denote conversions that may lose precision.
3 
Formatted output with printf 
Typical usage 
System.out.printf("%4d %8.2f", quantity, price); 
String str = String.format("%4d %8.2f", quantity, price); 
Each format specifier has the following form. See the tables for 
flags and conversion characters. 
Flags 
Flag Description Example 
+ Prints sign for positive and negative numbers +3333.33 
space Adds a space before positive numbers | 3333.33| 
0 Adds leading zeroes 003333.33 
- Left-justifies field |3333.33 | 
( Encloses negative number in parentheses (3333.33) 
, Adds group separators 3,333.33 
# (for f format) Always includes a decimal point 3,333. 
# (for x or o 
Adds 0x or 0 prefix 0xcafe 
format) 
$ Specifies the index of the argument to be formatted; 
for example, %1$d %1$x prints the first argument in 
decimal and hexadecimal 
Conversion characters 
Formatted output with MessageFormat 
Collections and common algorithms 
ArrayList An indexed sequence that grows and shrinks dynamically 
LinkedList An ordered sequence that allows efficient insertions and removal at 
ArrayDeque A double-ended queue that is implemented as a circular array 
HashSet An unordered collection that rejects duplicates 
TreeSet A sorted set 
EnumSet A set of enumerated type values 
LinkedHashSet A set that remembers the order in which elements were inserted 
PriorityQueue A collection that allows efficient removal of the smallest element 
HashMap A data structure that stores key/value associations 
TreeMap A map in which the keys are sorted 
EnumMap A map in which the keys belong to an enumerated type 
LinkedHashMap A map that remembers the order in which entries were added 
WeakHashMap A map with values that can be reclaimed by the garbage collector if 
List<String> strs = new ArrayList<String>(); Collect strings 
strs.add("Hello"); strs.add("World!"); Add strings 
for (String str : strs) System.out.println(str); Do something with all elements 
Remove elements that match a 
condition. The remove method 
removes the element returned by 
the preceding call to next. 
strs.addAll(strColl); Add all strings from another 
strs.addAll(Arrays.asList(args)) Add all strings from an array of 
strings. Arrays.asList makes a 
List wrapper for an array 
strs.removeAll(coll); Remove all elements of another 
collection. Uses equals for 
comparison 
Get or set an element at a 
specified index 
Insert or remove an element at 
a specified index, shifting the 
elements with higher index values 
Convert from collection to array 
Convert from array to list. Use 
the varargs form to make a small 
collection. 
Sort a list by the natural order of 
the elements, or with a custom 
comparator. 
Make a map that is traversed in 
insertion order (requires hashCode 
for key type). Use a TreeMap to 
traverse in sort order (requires that 
key type is comparable). 
Iterate through all entries of the 
map 
Get or set a value for a given key 
DZone, Inc. | www.dzone.com 
Core Java 
tech facts at your fingertips 
→ 
Typical usage: 
String msg = MessageFormat.format("On {1, date, 
long}, a {0} caused {2,number,currency} of damage.", 
"hurricane", new GregorianCalendar(2009, 0, 15). 
getTime(), 1.0E8); 
Yields "On January 1, 1999, a hurricane caused 
$100,000,000 of damage" 
n The nth item is denoted by {n,format,subformat} with 
optional formats and subformats shown below 
n {0} is the first item 
n The following table shows the available formats 
n Use single quotes for quoting, for example '{' for a literal 
left curly brace 
n Use '' for a literal single quote 
159 9F 
< Formats the same value as the previous specification; 
for example, %d %<x prints the same number in decimal 
and hexadecimal 
159 9F 
Conversion 
Character 
Description Example 
d Decimal integer 159 
x Hexadecimal integer 9f 
o Octal integer 237 
f Fixed-point floating-point 15.9 
e Exponential floating-point 1.59e+01 
g General floating-point (the shorter of e and f) 
a Hexadecimal floating-point 0x1.fccdp3 
s String Hello 
c Character H 
b boolean true 
h Hash code 42628b2 
tx Date and time See the next table 
% The percent symbol % 
n The platform-dependent line separator 
any location 
they are not used elsewhere 
IdentityHashMap A map with keys that are compared by ==, not equals 
Common Tasks 
in the collection 
Iterator<String> iter = strs.iterator(); 
while (iter.hasNext()) { 
String str = iter.next(); 
if (someCondition(str)) iter.remove(); 
collection of strings 
if (0 <= i && i < strs.size()) { 
str = strs.get(i); 
strs.set(i, "Hello"); 
strs.insert(i, "Hello"); 
str = strs.remove(i); 
String[] arr = new String[strs.size()]; 
strs.toArray(arr); 
String[] arr = ...; 
List<String> lst = Arrays.asList(arr); 
lst = Arrays.asList("foo", "bar", "baz"); 
List<String> lst = ...; 
lst.sort(); 
lst.sort(new Comparator<String>() { 
public int compare(String a, String b) { 
return a.length() - b.length(); 
} 
Map<String, Person> map = new 
LinkedHashMap<String, Person>(); 
for (Map.Entry<String, Person> entry : 
map.entrySet()) { 
String key = entry.getKey(); 
Person value = entry.getValue(); 
... 
Person key = map.get(str); // null if not found 
map.put(key, value); 
Character escape sequences 
} 
} 
} 
} 
b backspace u0008 
t tab u0009 
n newline u000A 
f form feed u000C 
r carriage return u000D 
" double quote 
' single quote 
 backslash 
uhhhh (hhhh is a hex number between 0000 and FFFF) The UTF-16 code point with value hhhh 
ooo (ooo is an octal number between 0 and 377) The character with octal value ooo 
Note: Unlike in C/C++, xhh is not allowed
4 
Regular Expression Formatted Output with MessageFormat, continued Syntax, continued 
short 1/15/09 
long January 15, 2009 
full Thursday, January 15, 2009 
short 3:45 PM 
long 3:45:00 PM PST 
full 3:45:00 PM PST 
DZone, Inc. | www.dzone.com 
Core Java 
tech facts at your fingertips 
Predefined Character Class Names 
Flags for matching 
The pattern matching can be adjusted with flags, for example: 
Pattern pattern = Pattern.compile(patternString, 
Pattern.CASE_INSENSITIVE + Pattern.UNICODE_CASE) 
Format Subformat Example 
number none 1,234.567 
integer 1,235 
currency $1,234.57 
percent 123,457% 
date none or medium Jan 15, 2009 
time none or medium 3:45:00 PM 
choice List of choices, separated by |. Each choice has 
n a lower bound (use -u221E for -∞) 
n a relational operator: < for “less than”, # or 
u2264 for ≤ 
n a message format string 
For example, {1,choice,0#no houses|1#one 
house|2#{1} houses} 
Regular Expressions 
Characters 
c The character c 
unnnn, xnn, 
0n, 0nn, 
0nnn 
The code unit with the given hex or octal value 
t, n, r, 
f, a, e 
The control characters tab, newline, return, form feed, alert, and escape 
cc The control character corresponding to the character c 
Character Classes 
[C1C2 . . .] Union: Any of the characters represented by C1C2 , . . . 
The Ci are characters, character ranges c1-c2, or character classes. 
Example: [a-zA-Z0-9_] 
[^C1C2 . . .] Complement: Characters not represented by any of C1C2 , . . . 
Example: [^0-9] 
[C1&&C2 &&. . .] Intersection: Characters represented by all of C1C2 , . . . 
Example: [A-f&&[^G-`]] 
Predefined Character Classes 
. Any character except line terminators (or any character if the DOTALL 
flag is set) 
d A digit [0-9] 
D A nondigit [^0-9] 
s A whitespace character [ tnrfx0B] 
S A nonwhitespace character 
w A word character [a-zA-Z0-9_] 
W A nonword character 
p{name} A named character class—see table below 
P{name} The complement of a named character class 
Boundary Matchers 
^ $ Beginning, end of input (or beginning, end of line in multiline mode) 
b A word boundary 
B A nonword boundary 
A Beginning of input 
z End of input 
Z End of input except final line terminator 
G End of previous match 
Quantifiers 
X? Optional X 
X* X, 0 or more times 
X+ X, 1 or more times 
X{n} X{n,} X{n,m} X n times, at least n times, between n and m times 
Quantifier Suffixes 
? Turn default (greedy) match into reluctant match 
+ Turn default (greedy) match into reluctant match 
Set Operations 
XY Any string from X, followed by any string from Y 
X |Y Any string from X or Y 
Grouping 
(X) Capture the string matching X as a group 
g The match of the gth group 
Escapes 
c The character c (must not be an alphabetic character) 
Q . . . E Quote . . . verbatim 
(? . . . ) Special construct—see API notes of Pattern class 
Lower ASCII lower case [a-z] 
Upper ASCII upper case [A-Z] 
Alpha ASCII alphabetic [A-Za-z] 
Digit ASCII digits [0-9] 
Alnum ASCII alphabetic or digit [A-Za-z0-9] 
XDigit Hex digits [0-9A-Fa-f] 
Print or Graph Printable ASCII character [x21-x7E] 
Punct ASCII nonalpha or digit [p{Print}&&P{Alnum}] 
ASCII All ASCII [x00-x7F] 
Cntrl ASCII Control character [x00-x1F] 
Blank Space or tab [ t] 
Space Whitespace [ tnrf0x0B] 
javaLowerCase Lower case, as determined by Character.isLowerCase() 
javaUpperCase Upper case, as determined by Character.isUpperCase() 
javaWhitespace White space, as determined by Character.isWhiteSpace() 
javaMirrored Mirrored, as determined by Character.isMirrored() 
InBlock Block is the name of a Unicode character block, with spaces 
removed, such as BasicLatin or Mongolian. 
Category or InCategory Category is the name of a Unicode character category such 
as L (letter) or Sc (currency symbol). 
Flag Description 
CASE_INSENSITIVE Match characters independently of the letter case. By default, 
this flag takes only US ASCII characters into account. 
UNICODE_CASE When used in combination with CASE_INSENSITIVE, use Unicode 
letter case for matching. 
MULTILINE ^ and $ match the beginning and end of a line, not the entire input. 
UNIX_LINES Only 'n' is recognized as a line terminator when matching ^ 
and $ in multiline mode. 
DOTALL When using this flag, the . symbol matches all characters, 
including line terminators. 
CANON_EQ Takes canonical equivalence of Unicode characters into account. 
For example, u followed by ¨ (diaeresis) matches ü. 
LITERAL The input string that specifies the pattern is treated as a sequence 
of literal characters, without special meanings for . [ ] etc. 
Common Tasks 
Regular Expression Syntax 
no house 
one house 
5 houses 
String[] words = str.split("s+"); Split a string along white 
space boundaries 
Pattern pattern = Pattern.compile("[0-9]+"); 
Matcher matcher = pattern.matcher(str); 
String result = matcher.replaceAll("#"); 
Replace all matches. 
Here we replace all digit 
sequences with a #. 
Pattern pattern = Pattern.compile("[0-9]+"); 
Matcher matcher = pattern.matcher(str); 
while (matcher.find()) { 
process(str.substring(matcher.start(), matcher.end())); 
} 
Find all matches. 
Pattern pattern = Pattern.compile( 
"(1?[0-9]):([0-5][0-9])[ap]m"); 
Matcher matcher = pattern.matcher(str); 
for (int i = 1; i <= matcher.groupCount(); i++) { 
process(matcher.group(i)); 
} 
Find all groups (indicated 
by parentheses in the 
pattern). Here we find 
the hours and minutes 
in a date.
5 
Property files 
JAR Files 
Get a logger for a category 
logger.info("Connection successful."); Logs a message of level FINE. 
Available levels are SEVERE, 
WARNING,INFO,CONFIG,FINE, 
FINER, FINEST, with 
corresponding methods severe, 
warning, and so on. 
Logs the stack trace of a 
Throwable 
logger.setLevel(Level.FINE); Sets the logging level to FINE. 
By default, the logging level is 
INFO, and less severe logging 
messages are not logged. 
Adds a file handler for saving the 
log records in a file. See the table 
below for the naming pattern. This 
handler uses a simple formatter 
instead of the XML formatter that 
is the default for file handlers. 
DZone, Inc. | www.dzone.com 
Core Java 
tech facts at your fingertips 
n Contain name/value pairs, separated by =, :, or whitespace 
n Whitespace around the name or before the start of the 
value is ignored 
n Lines can be continued by placing an  as the last character; 
leading whitespace on the continuation line is ignored 
button1.tooltip = This is a long  
tooltip text. 
n t n f r  uxxxx escapes are recognized (but not b 
or octal escapes) 
n Files are assumed to be encoded in ISO 8859-1; use 
native2ascii to encode non-ASCII characters into 
Unicode escapes 
n Blank lines and lines starting with # or ! are ignored 
Typical usage: 
Properties props = new Properties(); 
props.load(new FileInputStream("prog.properties")); 
String value = props.getProperty("button1.tooltip"); 
// null if not present 
Also used for resource bundles: 
ResourceBundle bundle = ResourceBundle.getBundle("prog"); 
// Searches for prog_en_US.properties, 
// prog_en.properties, etc. 
String value = bundle.getString("button1.tooltip"); 
n Used for storing applications, code libraries 
n By default, class files and other resources are stored in 
ZIP file format 
n META-INF/MANIFEST.MF contains JAR metadata 
n META-INF/services can contain service provider 
configuration 
n Use the jar utility to make JAR files 
jar Utility Options 
Option Description 
c Creates a new or empty archive and adds files to it. If any of the specified file 
names are directories, the jar program processes them recursively. 
C Temporarily changes the directory. For example, 
jar cvfC myprog.jar classes *.class 
changes to the classes subdirectory to add class files. 
e Creates a Main-Class entry in the manifest 
jar cvfe myprog.jar com.mycom.mypkg.MainClass files 
f Specifies the JAR file name as the second command-line argument. If this 
parameter is missing, jar will write the result to standard output (when creating a 
JAR file) or read it from standard input (when extracting or tabulating a JAR file). 
i Creates an index file (for speeding up lookups in a large archive) 
m Adds a manifest to the JAR file. 
jar cvfm myprog.jar mymanifest.mf files 
M Does not create a manifest file for the entries. 
t Displays the table of contents. 
jar tvf myprog.jar 
u Updates an existing JAR file 
jar uf myprog.jar com/mycom/mypkg/SomeClass.class 
v Generates verbose output. 
x Extracts files. If you supply one or more file names, only those files are 
extracted. Otherwise, all files are extracted. 
jar xf myprog.jar 
O Stores without ZIP compression 
LOGGING 
Common Tasks 
Logger logger = 
Logger.getLogger("com.mycompany.myprog.mycategory"); 
logger.log(Level.SEVERE, "Unexpected exception", 
throwable); 
Handler handler = new FileHandler("%h/myapp.log", 
SIZE_LIMIT, LOG_ROTATION_COUNT); 
handler.setFormatter(new SimpleFormatter()); 
logger.addHandler(handler); 
Logging Configuration Files 
The logging configuration can be configured through a logging 
configuration file, by default jre/lib/logging.properties. 
Another file can be specified with the system property java. 
util.logging.config.file when starting the virtual machine. 
(Note that the LogManager runs before main.) 
Configuration Property Description Default 
loggerName.level The logging level of the logger by the 
given name 
None; the logger 
inherits the handler 
from its parent 
handlers A whitespace or comma-separated list 
of class names for the root logger. An 
instance is created for each class name, 
using the default constructor. 
java.util.logging. 
ConsoleHandler 
loggerName.handlers A whitespace or comma-separated list 
of class names for the given logger 
None 
loggerName. 
useParenthandlers 
false if the parent logger's handlers 
(and ultimately the root logger's 
handlers) should not be used 
true 
config A whitespace or comma-separated list 
of class names for initialization. 
None 
java.util.logging. 
FileHandler.level 
java.util.logging. 
ConsoleHandler.level 
The default handler level Level.ALL for 
FileHandler, 
Level.INFO for 
ConsoleHandler 
java.util.logging. 
FileHandler.formatter 
java.util.logging. 
ConsoleHandler.formatter 
The class name of the default filter None 
java.util.logging. 
FileHandler.formatter 
java.util.logging. 
ConsoleHandler.formatter 
The class name of the default formatter java.util.logging. 
XMLFormatter for 
FileHandler, 
java.util.logging. 
SimpleFormatter for 
ConsoleHandler 
java.util.logging. 
FileHandler.encoding 
java.util.logging. 
ConsoleHandler.encoding 
The default encoding default platform 
encoding 
java.util.logging. 
FileHandler.limit 
The default limit for rotating log files, 
in bytes 
0 (No limit), but set 
to 50000 in jre/lib/ 
logging.properties 
java.util.logging. 
FileHandler.count 
The default number of rotated log files 1 
java.util.logging. 
FileHandler.pattern 
The default naming pattern for log files. 
The following tokens are replaced when 
the file is created: 
%h/java%u.log 
java.util.logging. 
FileHandler.append 
The default append mode for file loggers; 
true to append to an existing log file 
false 
Token Description 
/ Path separator 
%t System temporary directory 
%h Value of user.home system property 
%g The generation number of rotated logs 
%u A unique number for resolving 
naming conflicts 
%% The % character
Core Java 
6 
tech facts at your fingertips 
Common javac Options Common java Options 
DZone, Inc. 
1251 NW Maynard 
Cary, NC 27513 
888.678.0399 
919.678.0300 
Refcardz Feedback Welcome 
refcardz@dzone.com 
Sponsorship Opportunities 
sales@dzone.com 
Option Purpose 
-cp or -classpath Sets the class path, used to search for class files. The class path is a 
list of directories, JAR files, or expressions of the form directory/'*' 
(Unix) or directory* (Windows). The latter refers to all JAR files 
in the given directory. Class path items are separated by : (Unix) 
or ; (Windows). If no class path is specified, it is set to the current 
directory. If a class path is specified, the current directory is not 
automatically included—add a . item if you want to include it. 
-sourcepath Sets the path used to search for source files. If source and class files 
are present for a given file, the source is compiled if it is newer. If no 
source path is specified, it is set to the current directory. 
-d Sets the path used to place the class files. Use this option to separate 
.java and .class files. 
-source Sets the source level. Valid values are 1.3, 1.4, 1.5, 1.6, 5, 6 
-deprecation Gives detail information about the use of deprecated features 
-Xlint:unchecked Gives detail information about unchecked type conversion warnings 
Copyright © 2008 DZone, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, 
or otherwise, without prior written permission of the publisher. Reference: Core Java, Volume I and Core Java, Volume II, Cay S. Horstmann and Gary Cornell, Sun Microsystems Press, 1996-2007. 
Version 1.0 
$7.95 
ISBN-13: 978-1-934238-26-4 
ISBN-10: 1-934238-26-0 
9 781934 238264 
5 0 7 9 5 
ABOUT THE AUTHOR 
Core Java, now in 
its 8th edition, is a 
no-nonsense tutorial 
and reliable reference 
into all aspects of 
Java SE 6. 
RECOMMENDED BOOKS 
BUY NOW 
books.dzone.com/books/corejava1 
books.dzone.com/books/corejava2 
Cay S. Horstmann 
Cay S. Horstmann has written many books on C++, Java and object-oriented 
development, is the series editor for Core Books at Prentice-Hall 
and a frequent speaker at computer industry conferences. For four years, 
Cay was VP and CTO of an Internet startup that went from 3 people in a 
tiny office to a public company. He is now a computer science professor 
at San Jose State University. He was elected Java Champion in 2005. 
Publications 
n Core Java, with Gary Cornell (Sun Microsystems Press 1996–2007) 
n Core JavaServer Faces, with David Geary (Sun Microsystems Press 2004–2006) 
n Big Java (John Wiley & Sons 2001–2007) 
Web Site Blog 
http://horstmann.com http://weblogs.java.net/blog/cayhorstmann 
Option Purpose 
-cp or -classpath Sets the class path, used to search for class files. See the previous 
table for details. Note that javac can succeed when java fails if the 
current directory is on the source path but not the class path. 
-ea or 
-enableassertions 
Enable assertions. By default, assertions are disabled. 
-Dproperty=value Sets a system property that can be retrieved by System. 
getProperty(String) 
-jar Runs a program contained in a JAR file whose manifest has a 
Main-Class entry. When this option is used, the class path is ignored. 
-verbose Shows the classes that are loaded. This option may be useful to 
debug class loading problems. 
-Xmssize 
-Xmxsize 
Sets the initial or maximum heap size. The size is a value in bytes. 
Add a suffix k or m for kilobytes or megabytes, for example, -Xmx10m 
Get More FREE Refcardz. Visit refcardz.com now! 
Core Seam 
Core CSS: Part III 
Hibernate Search 
Equinox 
EMF 
XML 
JSP Expression Language 
ALM Best Practices 
HTML and XHTML 
Available: 
Essential Ruby 
Essential MySQL 
JUnit and EasyMock 
Getting Started with MyEclipse 
Spring Annotations 
Core Java 
Core CSS: Part II 
PHP 
Getting Started with JPA 
JavaServer Faces 
Core CSS: Part I 
Struts2 
Core .NET 
Very First Steps in Flex 
C# 
Groovy 
NetBeans IDE 6.1 Java Editor 
RSS and Atom 
GlassFish Application Server 
Silverlight 2 
Visit refcardz.com for a complete listing of available Refcardz. 
Design Patterns 
Published June 2008 
F RE E 
DZone communities deliver over 4 million pages each month to 
more than 1.7 million software developers, architects and decision 
makers. DZone offers something for everyone, including news, 
tutorials, cheatsheets, blogs, feature articles, source code and more. 
“DZone is a developer’s dream,” says PC Magazine.
Ad

More Related Content

What's hot (20)

Java generics final
Java generics finalJava generics final
Java generics final
Akshay Chaudhari
 
Java generics
Java genericsJava generics
Java generics
Hosein Zare
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
Abdul Aziz
 
Java tut1
Java tut1Java tut1
Java tut1
Ajmal Khan
 
Java Generics
Java GenericsJava Generics
Java Generics
jeslie
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
Eelco Visser
 
DITEC - Programming with Java
DITEC - Programming with JavaDITEC - Programming with Java
DITEC - Programming with Java
Rasan Samarasinghe
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
Intro C# Book
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
Sunil OS
 
Generic Programming
Generic ProgrammingGeneric Programming
Generic Programming
Muhammad Alhalaby
 
Python The basics
Python   The basicsPython   The basics
Python The basics
Bobby Murugesan
 
Java New Programming Features
Java New Programming FeaturesJava New Programming Features
Java New Programming Features
tarun308
 
On Parameterised Types and Java Generics
On Parameterised Types and Java GenericsOn Parameterised Types and Java Generics
On Parameterised Types and Java Generics
Yann-Gaël Guéhéneuc
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
Ganesh Samarthyam
 
C traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmersC traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmers
Richard Thomson
 
Java Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and PitfallsJava Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and Pitfalls
Rakesh Waghela
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
Getting rid of backtracking
Getting rid of backtrackingGetting rid of backtracking
Getting rid of backtracking
Dr. Jan Köhnlein
 
Preparing Java 7 Certifications
Preparing Java 7 CertificationsPreparing Java 7 Certifications
Preparing Java 7 Certifications
Giacomo Veneri
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
Java Generics
Java GenericsJava Generics
Java Generics
jeslie
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
Eelco Visser
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
Intro C# Book
 
Java New Programming Features
Java New Programming FeaturesJava New Programming Features
Java New Programming Features
tarun308
 
On Parameterised Types and Java Generics
On Parameterised Types and Java GenericsOn Parameterised Types and Java Generics
On Parameterised Types and Java Generics
Yann-Gaël Guéhéneuc
 
C traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmersC traps and pitfalls for C++ programmers
C traps and pitfalls for C++ programmers
Richard Thomson
 
Java Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and PitfallsJava Generics Introduction - Syntax Advantages and Pitfalls
Java Generics Introduction - Syntax Advantages and Pitfalls
Rakesh Waghela
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
Preparing Java 7 Certifications
Preparing Java 7 CertificationsPreparing Java 7 Certifications
Preparing Java 7 Certifications
Giacomo Veneri
 

Similar to core java (20)

Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
xcoda
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
ssuserb1a18d
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
caswenson
 
Java q ref 2018
Java q ref 2018Java q ref 2018
Java q ref 2018
Christopher Akinlade
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
Utkarsh Sengar
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
Simon Ritter
 
Java Cheat Sheet
Java Cheat SheetJava Cheat Sheet
Java Cheat Sheet
Saeid Zebardast
 
C tutorial
C tutorialC tutorial
C tutorial
Anurag Sukhija
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
princepavan
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
princepavan
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
Prashant Kalkar
 
Computational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdfComputational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdf
SadhikaPolamarasetti1
 
Computer programming 2 Lesson 12
Computer programming 2  Lesson 12Computer programming 2  Lesson 12
Computer programming 2 Lesson 12
MLG College of Learning, Inc
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
guest5c8bd1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
Vijay A Raj
 
C++ theory
C++ theoryC++ theory
C++ theory
Shyam Khant
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOF
Dror Bereznitsky
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
sholavanalli
 
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
manikbuma
 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
xcoda
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
ssuserb1a18d
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
caswenson
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
Utkarsh Sengar
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
Simon Ritter
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
princepavan
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
princepavan
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
Prashant Kalkar
 
Computational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdfComputational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdf
SadhikaPolamarasetti1
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOF
Dror Bereznitsky
 
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
manikbuma
 
Ad

Recently uploaded (20)

P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
Ad

core java

  • 1. DZone, Inc. | www.dzone.com tech facts at your fingertips CONTENTS INCLUDE: n Java Keywords n Standard Java Packages n Character Escape Sequences n Collections and Common Algorithms n Regular Expressions n JAR Files This refcard gives you an overview of key aspects of the Java language and cheat sheets on the core library (formatted output, collections, regular expressions, logging, properties) as well as the most commonly used tools (javac, java, jar). Core Java By Cay S. Horstmann Java Keywords, continued About CORE JAVA Java Keywords Core Java www.dzone.com Get More Refcardz! Visit refcardz.com Get More Refcardz (They’re free!) n Authoritative content n Designed for developers n Written by top experts n Latest tools & technologies n Hot tips & examples n Bonus content online n New issue every 1-2 weeks Subscribe Now for FREE! Refcardz.com → Keyword Description Example abstract an abstract class or method abstract class Writable { public abstract void write(Writer out); public void save(String filename) { ... } } assert with assertions enabled, throws an error if condition not fulfilled assert param != null; Note: Run with -ea to enable assertions boolean the Boolean type with values true and false boolean more = false; break breaks out of a switch or loop while ((ch = in.next()) != -1) { if (ch == 'n') break; process(ch); } Note: Also see switch byte the 8-bit integer type byte b = -1; // Not the same as 0xFF Note: Be careful with bytes < 0 case a case of a switch see switch catch the clause of a try block catching an exception see try char the Unicode character type char input = 'Q'; class defines a class type class Person { private String name; public Person(String aName) { name = aName; } public void print() { System.out.println(name); } } const not used continue continues at the end of a loop while ((ch = in.next()) != -1) { if (ch == ' ') continue; process(ch); } default the default clause of a switch see switch do the top of a do/while loop do { ch = in.next(); } while (ch == ' '); double the double-precision floating-number type double oneHalf = 0.5; else the else clause of an if statement see if enum an enumerated type enum Mood { SAD, HAPPY }; extends defines the parent class of a class class Student extends Person { private int id; public Student(String name, int anId) { ... } public void print() { ... } } final a constant, or a class or method that cannot be overridden public static final int DEFAULT_ID = 0; Keyword Description Example finally the part of a try block that is always executed see try float the single-precision floating-point type float oneHalf = 0.5F; for a loop type for (int i = 10; i >= 0; i--) System.out.println(i); for (String s : line.split("s+")) System.out.println(s); Note: In the “generalized” for loop, the expression after the : must be an array or an Iterable goto not used if a conditional statement if (input == 'Q') System.exit(0); else more = true; implements defines the interface(s) that a class implements class Student implements Printable { ... } import imports a package import java.util.ArrayList; import com.dzone.refcardz.*; instanceof tests if an object is an instance of a class if (fred instanceof Student) value = ((Student) fred).getId(); Note: null instanceof T is always false int the 32-bit integer type int value = 0; interface an abstract type with methods that a class can implement interface Printable { void print(); } long the 64-bit long integer type long worldPopulation = 6710044745L; native a method implemented by the host system new allocates a new object or array Person fred = new Person("Fred"); null a null reference Person optional = null; package a package of classes package com.dzone.refcardz; private a feature that is accessible only by methods of this class see class protected a feature that is accessible only by methods of this class, its children, and other classes in the same package class Student { protected int id; ... } #24
  • 2. Core Java 2 Primitive types DZone, Inc. | www.dzone.com tech facts at your fingertips Java Keywords, continued Keyword Description Example public a feature that is accessible by methods of all classes see class return returns from a method int getId() { return id; } short the 16-bit integer type short skirtLength = 24; static a feature that is unique to its class, not to objects of its class public class WriteUtil { public static void write(Writable[] ws, String filename); public static final String DEFAULT_EXT = ".dat"; } strictfp Use strict rules for floating-point computations super invoke a superclass constructor or method public Student(String name, int anId) { super(name); id = anId; } public void print() { super.print(); System.out.println(id); } switch a selection statement switch (ch) { case 'Q': case 'q': more = false; break; case ' '; break; default: process(ch); break; } Note: If you omit a break, processing continues with the next case. synchronized a method or code block that is atomic to a thread public synchronized void addGrade(String gr) { grades.add(gr); } this the implicit argument of a method, or a constructor of this class public Student(String id) {this.id = id;} public Student() { this(""); } throw throws an exception if (param == null) throw new IllegalArgumentException(); throws the exceptions that a method can throw public void print() throws PrinterException, IOException transient marks data that should not be persistent class Student { private transient Data cachedData; ... } try a block of code that traps exceptions try { try { fred.print(out); } catch (PrinterException ex) { ex.printStackTrace(); } } finally { out.close(); } void denotes a method that returns no value public void print() { ... } volatile ensures that a field is coherently accessed by multiple threads class Student { private volatile int nextId; ... } while a loop while (in.hasNext()) process(in.next()); Operator Precedence Operators with the same precedence Notes [] . () (method call) Left to right ! ~ ++ -- + (unary) – (unary) () (cast) new Right to left ~ flips each bit of a number * / % Left to right Be careful when using % with negative numbers. -a % b == -(a % b), but a % -b == a % b. For example, -7 % 4 == -3, 7 % -4 == 3. + - Left to right << >> >>> Left to right >> is arithmetic shift (n >> 1 == n / 2 for positive and negative numbers), >>> is logical shift (adding 0 to the highest bits). The right hand side is reduced modulo 32 if the left hand side is an int or modulo 64 if the left hand side is a long. For example, 1 << 35 == 1 << 3. < <= > >= instanceof Left to right null instanceof T is always false == != Left to right Checks for identity. Use equals to check for structural equality. & Left to right Bitwise AND; no lazy evaluation with bool arguments ^ Left to right Bitwise XOR | Left to right Bitwise OR; no lazy evaluation with bool arguments && Left to right || Left to right ?: Right to left = += -= *= /= %= &= |= ^= <<= >>= >>>= Right to left Type Size Range Notes int 4 bytes –2,147,483,648 to 2,147,483, 647 (just over 2 billion) The wrapper type is Integer. Use BigInteger for arbitrary precision integers. short 2 bytes –32,768 to 32,767 long 8 bytes –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Literals end with L (e.g. 1L). byte 1 byte –128 to 127 Note that the range is not 0 ... 255. float 4 bytes approximately ±3.40282347E+38F (6–7 significant decimal digits) Literals end with F (e.g. 0.5F) double 8 bytes approximately ±1.79769313486231570E+308 (15 significant decimal digits) Use BigDecimal for arbitrary precision floating-point numbers. char 2 bytes u0000 to uFFFF The wrapper type is Character. Unicode characters > U+FFFF require two char values. boolean true or false Standard Java Packages java.applet Applets (Java programs that run inside a web page) java.awt Graphics and graphical user interfaces java.beans Support for JavaBeans components (classes with properties and event listeners) java.io Input and output java.lang Language support java.math Arbitrary-precision numbers java.net Networking java.nio “New” (memory-mapped) I/O java.rmi Remote method invocations java.security Security support java.sql Database support java.text Internationalized formatting of text and numbers java.util Utilities (including data structures, concurrency, regular expressions, and logging) Legal conversions between primitive types Dotted arrows denote conversions that may lose precision.
  • 3. 3 Formatted output with printf Typical usage System.out.printf("%4d %8.2f", quantity, price); String str = String.format("%4d %8.2f", quantity, price); Each format specifier has the following form. See the tables for flags and conversion characters. Flags Flag Description Example + Prints sign for positive and negative numbers +3333.33 space Adds a space before positive numbers | 3333.33| 0 Adds leading zeroes 003333.33 - Left-justifies field |3333.33 | ( Encloses negative number in parentheses (3333.33) , Adds group separators 3,333.33 # (for f format) Always includes a decimal point 3,333. # (for x or o Adds 0x or 0 prefix 0xcafe format) $ Specifies the index of the argument to be formatted; for example, %1$d %1$x prints the first argument in decimal and hexadecimal Conversion characters Formatted output with MessageFormat Collections and common algorithms ArrayList An indexed sequence that grows and shrinks dynamically LinkedList An ordered sequence that allows efficient insertions and removal at ArrayDeque A double-ended queue that is implemented as a circular array HashSet An unordered collection that rejects duplicates TreeSet A sorted set EnumSet A set of enumerated type values LinkedHashSet A set that remembers the order in which elements were inserted PriorityQueue A collection that allows efficient removal of the smallest element HashMap A data structure that stores key/value associations TreeMap A map in which the keys are sorted EnumMap A map in which the keys belong to an enumerated type LinkedHashMap A map that remembers the order in which entries were added WeakHashMap A map with values that can be reclaimed by the garbage collector if List<String> strs = new ArrayList<String>(); Collect strings strs.add("Hello"); strs.add("World!"); Add strings for (String str : strs) System.out.println(str); Do something with all elements Remove elements that match a condition. The remove method removes the element returned by the preceding call to next. strs.addAll(strColl); Add all strings from another strs.addAll(Arrays.asList(args)) Add all strings from an array of strings. Arrays.asList makes a List wrapper for an array strs.removeAll(coll); Remove all elements of another collection. Uses equals for comparison Get or set an element at a specified index Insert or remove an element at a specified index, shifting the elements with higher index values Convert from collection to array Convert from array to list. Use the varargs form to make a small collection. Sort a list by the natural order of the elements, or with a custom comparator. Make a map that is traversed in insertion order (requires hashCode for key type). Use a TreeMap to traverse in sort order (requires that key type is comparable). Iterate through all entries of the map Get or set a value for a given key DZone, Inc. | www.dzone.com Core Java tech facts at your fingertips → Typical usage: String msg = MessageFormat.format("On {1, date, long}, a {0} caused {2,number,currency} of damage.", "hurricane", new GregorianCalendar(2009, 0, 15). getTime(), 1.0E8); Yields "On January 1, 1999, a hurricane caused $100,000,000 of damage" n The nth item is denoted by {n,format,subformat} with optional formats and subformats shown below n {0} is the first item n The following table shows the available formats n Use single quotes for quoting, for example '{' for a literal left curly brace n Use '' for a literal single quote 159 9F < Formats the same value as the previous specification; for example, %d %<x prints the same number in decimal and hexadecimal 159 9F Conversion Character Description Example d Decimal integer 159 x Hexadecimal integer 9f o Octal integer 237 f Fixed-point floating-point 15.9 e Exponential floating-point 1.59e+01 g General floating-point (the shorter of e and f) a Hexadecimal floating-point 0x1.fccdp3 s String Hello c Character H b boolean true h Hash code 42628b2 tx Date and time See the next table % The percent symbol % n The platform-dependent line separator any location they are not used elsewhere IdentityHashMap A map with keys that are compared by ==, not equals Common Tasks in the collection Iterator<String> iter = strs.iterator(); while (iter.hasNext()) { String str = iter.next(); if (someCondition(str)) iter.remove(); collection of strings if (0 <= i && i < strs.size()) { str = strs.get(i); strs.set(i, "Hello"); strs.insert(i, "Hello"); str = strs.remove(i); String[] arr = new String[strs.size()]; strs.toArray(arr); String[] arr = ...; List<String> lst = Arrays.asList(arr); lst = Arrays.asList("foo", "bar", "baz"); List<String> lst = ...; lst.sort(); lst.sort(new Comparator<String>() { public int compare(String a, String b) { return a.length() - b.length(); } Map<String, Person> map = new LinkedHashMap<String, Person>(); for (Map.Entry<String, Person> entry : map.entrySet()) { String key = entry.getKey(); Person value = entry.getValue(); ... Person key = map.get(str); // null if not found map.put(key, value); Character escape sequences } } } } b backspace u0008 t tab u0009 n newline u000A f form feed u000C r carriage return u000D " double quote ' single quote backslash uhhhh (hhhh is a hex number between 0000 and FFFF) The UTF-16 code point with value hhhh ooo (ooo is an octal number between 0 and 377) The character with octal value ooo Note: Unlike in C/C++, xhh is not allowed
  • 4. 4 Regular Expression Formatted Output with MessageFormat, continued Syntax, continued short 1/15/09 long January 15, 2009 full Thursday, January 15, 2009 short 3:45 PM long 3:45:00 PM PST full 3:45:00 PM PST DZone, Inc. | www.dzone.com Core Java tech facts at your fingertips Predefined Character Class Names Flags for matching The pattern matching can be adjusted with flags, for example: Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE + Pattern.UNICODE_CASE) Format Subformat Example number none 1,234.567 integer 1,235 currency $1,234.57 percent 123,457% date none or medium Jan 15, 2009 time none or medium 3:45:00 PM choice List of choices, separated by |. Each choice has n a lower bound (use -u221E for -∞) n a relational operator: < for “less than”, # or u2264 for ≤ n a message format string For example, {1,choice,0#no houses|1#one house|2#{1} houses} Regular Expressions Characters c The character c unnnn, xnn, 0n, 0nn, 0nnn The code unit with the given hex or octal value t, n, r, f, a, e The control characters tab, newline, return, form feed, alert, and escape cc The control character corresponding to the character c Character Classes [C1C2 . . .] Union: Any of the characters represented by C1C2 , . . . The Ci are characters, character ranges c1-c2, or character classes. Example: [a-zA-Z0-9_] [^C1C2 . . .] Complement: Characters not represented by any of C1C2 , . . . Example: [^0-9] [C1&&C2 &&. . .] Intersection: Characters represented by all of C1C2 , . . . Example: [A-f&&[^G-`]] Predefined Character Classes . Any character except line terminators (or any character if the DOTALL flag is set) d A digit [0-9] D A nondigit [^0-9] s A whitespace character [ tnrfx0B] S A nonwhitespace character w A word character [a-zA-Z0-9_] W A nonword character p{name} A named character class—see table below P{name} The complement of a named character class Boundary Matchers ^ $ Beginning, end of input (or beginning, end of line in multiline mode) b A word boundary B A nonword boundary A Beginning of input z End of input Z End of input except final line terminator G End of previous match Quantifiers X? Optional X X* X, 0 or more times X+ X, 1 or more times X{n} X{n,} X{n,m} X n times, at least n times, between n and m times Quantifier Suffixes ? Turn default (greedy) match into reluctant match + Turn default (greedy) match into reluctant match Set Operations XY Any string from X, followed by any string from Y X |Y Any string from X or Y Grouping (X) Capture the string matching X as a group g The match of the gth group Escapes c The character c (must not be an alphabetic character) Q . . . E Quote . . . verbatim (? . . . ) Special construct—see API notes of Pattern class Lower ASCII lower case [a-z] Upper ASCII upper case [A-Z] Alpha ASCII alphabetic [A-Za-z] Digit ASCII digits [0-9] Alnum ASCII alphabetic or digit [A-Za-z0-9] XDigit Hex digits [0-9A-Fa-f] Print or Graph Printable ASCII character [x21-x7E] Punct ASCII nonalpha or digit [p{Print}&&P{Alnum}] ASCII All ASCII [x00-x7F] Cntrl ASCII Control character [x00-x1F] Blank Space or tab [ t] Space Whitespace [ tnrf0x0B] javaLowerCase Lower case, as determined by Character.isLowerCase() javaUpperCase Upper case, as determined by Character.isUpperCase() javaWhitespace White space, as determined by Character.isWhiteSpace() javaMirrored Mirrored, as determined by Character.isMirrored() InBlock Block is the name of a Unicode character block, with spaces removed, such as BasicLatin or Mongolian. Category or InCategory Category is the name of a Unicode character category such as L (letter) or Sc (currency symbol). Flag Description CASE_INSENSITIVE Match characters independently of the letter case. By default, this flag takes only US ASCII characters into account. UNICODE_CASE When used in combination with CASE_INSENSITIVE, use Unicode letter case for matching. MULTILINE ^ and $ match the beginning and end of a line, not the entire input. UNIX_LINES Only 'n' is recognized as a line terminator when matching ^ and $ in multiline mode. DOTALL When using this flag, the . symbol matches all characters, including line terminators. CANON_EQ Takes canonical equivalence of Unicode characters into account. For example, u followed by ¨ (diaeresis) matches ü. LITERAL The input string that specifies the pattern is treated as a sequence of literal characters, without special meanings for . [ ] etc. Common Tasks Regular Expression Syntax no house one house 5 houses String[] words = str.split("s+"); Split a string along white space boundaries Pattern pattern = Pattern.compile("[0-9]+"); Matcher matcher = pattern.matcher(str); String result = matcher.replaceAll("#"); Replace all matches. Here we replace all digit sequences with a #. Pattern pattern = Pattern.compile("[0-9]+"); Matcher matcher = pattern.matcher(str); while (matcher.find()) { process(str.substring(matcher.start(), matcher.end())); } Find all matches. Pattern pattern = Pattern.compile( "(1?[0-9]):([0-5][0-9])[ap]m"); Matcher matcher = pattern.matcher(str); for (int i = 1; i <= matcher.groupCount(); i++) { process(matcher.group(i)); } Find all groups (indicated by parentheses in the pattern). Here we find the hours and minutes in a date.
  • 5. 5 Property files JAR Files Get a logger for a category logger.info("Connection successful."); Logs a message of level FINE. Available levels are SEVERE, WARNING,INFO,CONFIG,FINE, FINER, FINEST, with corresponding methods severe, warning, and so on. Logs the stack trace of a Throwable logger.setLevel(Level.FINE); Sets the logging level to FINE. By default, the logging level is INFO, and less severe logging messages are not logged. Adds a file handler for saving the log records in a file. See the table below for the naming pattern. This handler uses a simple formatter instead of the XML formatter that is the default for file handlers. DZone, Inc. | www.dzone.com Core Java tech facts at your fingertips n Contain name/value pairs, separated by =, :, or whitespace n Whitespace around the name or before the start of the value is ignored n Lines can be continued by placing an as the last character; leading whitespace on the continuation line is ignored button1.tooltip = This is a long tooltip text. n t n f r uxxxx escapes are recognized (but not b or octal escapes) n Files are assumed to be encoded in ISO 8859-1; use native2ascii to encode non-ASCII characters into Unicode escapes n Blank lines and lines starting with # or ! are ignored Typical usage: Properties props = new Properties(); props.load(new FileInputStream("prog.properties")); String value = props.getProperty("button1.tooltip"); // null if not present Also used for resource bundles: ResourceBundle bundle = ResourceBundle.getBundle("prog"); // Searches for prog_en_US.properties, // prog_en.properties, etc. String value = bundle.getString("button1.tooltip"); n Used for storing applications, code libraries n By default, class files and other resources are stored in ZIP file format n META-INF/MANIFEST.MF contains JAR metadata n META-INF/services can contain service provider configuration n Use the jar utility to make JAR files jar Utility Options Option Description c Creates a new or empty archive and adds files to it. If any of the specified file names are directories, the jar program processes them recursively. C Temporarily changes the directory. For example, jar cvfC myprog.jar classes *.class changes to the classes subdirectory to add class files. e Creates a Main-Class entry in the manifest jar cvfe myprog.jar com.mycom.mypkg.MainClass files f Specifies the JAR file name as the second command-line argument. If this parameter is missing, jar will write the result to standard output (when creating a JAR file) or read it from standard input (when extracting or tabulating a JAR file). i Creates an index file (for speeding up lookups in a large archive) m Adds a manifest to the JAR file. jar cvfm myprog.jar mymanifest.mf files M Does not create a manifest file for the entries. t Displays the table of contents. jar tvf myprog.jar u Updates an existing JAR file jar uf myprog.jar com/mycom/mypkg/SomeClass.class v Generates verbose output. x Extracts files. If you supply one or more file names, only those files are extracted. Otherwise, all files are extracted. jar xf myprog.jar O Stores without ZIP compression LOGGING Common Tasks Logger logger = Logger.getLogger("com.mycompany.myprog.mycategory"); logger.log(Level.SEVERE, "Unexpected exception", throwable); Handler handler = new FileHandler("%h/myapp.log", SIZE_LIMIT, LOG_ROTATION_COUNT); handler.setFormatter(new SimpleFormatter()); logger.addHandler(handler); Logging Configuration Files The logging configuration can be configured through a logging configuration file, by default jre/lib/logging.properties. Another file can be specified with the system property java. util.logging.config.file when starting the virtual machine. (Note that the LogManager runs before main.) Configuration Property Description Default loggerName.level The logging level of the logger by the given name None; the logger inherits the handler from its parent handlers A whitespace or comma-separated list of class names for the root logger. An instance is created for each class name, using the default constructor. java.util.logging. ConsoleHandler loggerName.handlers A whitespace or comma-separated list of class names for the given logger None loggerName. useParenthandlers false if the parent logger's handlers (and ultimately the root logger's handlers) should not be used true config A whitespace or comma-separated list of class names for initialization. None java.util.logging. FileHandler.level java.util.logging. ConsoleHandler.level The default handler level Level.ALL for FileHandler, Level.INFO for ConsoleHandler java.util.logging. FileHandler.formatter java.util.logging. ConsoleHandler.formatter The class name of the default filter None java.util.logging. FileHandler.formatter java.util.logging. ConsoleHandler.formatter The class name of the default formatter java.util.logging. XMLFormatter for FileHandler, java.util.logging. SimpleFormatter for ConsoleHandler java.util.logging. FileHandler.encoding java.util.logging. ConsoleHandler.encoding The default encoding default platform encoding java.util.logging. FileHandler.limit The default limit for rotating log files, in bytes 0 (No limit), but set to 50000 in jre/lib/ logging.properties java.util.logging. FileHandler.count The default number of rotated log files 1 java.util.logging. FileHandler.pattern The default naming pattern for log files. The following tokens are replaced when the file is created: %h/java%u.log java.util.logging. FileHandler.append The default append mode for file loggers; true to append to an existing log file false Token Description / Path separator %t System temporary directory %h Value of user.home system property %g The generation number of rotated logs %u A unique number for resolving naming conflicts %% The % character
  • 6. Core Java 6 tech facts at your fingertips Common javac Options Common java Options DZone, Inc. 1251 NW Maynard Cary, NC 27513 888.678.0399 919.678.0300 Refcardz Feedback Welcome [email protected] Sponsorship Opportunities [email protected] Option Purpose -cp or -classpath Sets the class path, used to search for class files. The class path is a list of directories, JAR files, or expressions of the form directory/'*' (Unix) or directory* (Windows). The latter refers to all JAR files in the given directory. Class path items are separated by : (Unix) or ; (Windows). If no class path is specified, it is set to the current directory. If a class path is specified, the current directory is not automatically included—add a . item if you want to include it. -sourcepath Sets the path used to search for source files. If source and class files are present for a given file, the source is compiled if it is newer. If no source path is specified, it is set to the current directory. -d Sets the path used to place the class files. Use this option to separate .java and .class files. -source Sets the source level. Valid values are 1.3, 1.4, 1.5, 1.6, 5, 6 -deprecation Gives detail information about the use of deprecated features -Xlint:unchecked Gives detail information about unchecked type conversion warnings Copyright © 2008 DZone, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Reference: Core Java, Volume I and Core Java, Volume II, Cay S. Horstmann and Gary Cornell, Sun Microsystems Press, 1996-2007. Version 1.0 $7.95 ISBN-13: 978-1-934238-26-4 ISBN-10: 1-934238-26-0 9 781934 238264 5 0 7 9 5 ABOUT THE AUTHOR Core Java, now in its 8th edition, is a no-nonsense tutorial and reliable reference into all aspects of Java SE 6. RECOMMENDED BOOKS BUY NOW books.dzone.com/books/corejava1 books.dzone.com/books/corejava2 Cay S. Horstmann Cay S. Horstmann has written many books on C++, Java and object-oriented development, is the series editor for Core Books at Prentice-Hall and a frequent speaker at computer industry conferences. For four years, Cay was VP and CTO of an Internet startup that went from 3 people in a tiny office to a public company. He is now a computer science professor at San Jose State University. He was elected Java Champion in 2005. Publications n Core Java, with Gary Cornell (Sun Microsystems Press 1996–2007) n Core JavaServer Faces, with David Geary (Sun Microsystems Press 2004–2006) n Big Java (John Wiley & Sons 2001–2007) Web Site Blog http://horstmann.com http://weblogs.java.net/blog/cayhorstmann Option Purpose -cp or -classpath Sets the class path, used to search for class files. See the previous table for details. Note that javac can succeed when java fails if the current directory is on the source path but not the class path. -ea or -enableassertions Enable assertions. By default, assertions are disabled. -Dproperty=value Sets a system property that can be retrieved by System. getProperty(String) -jar Runs a program contained in a JAR file whose manifest has a Main-Class entry. When this option is used, the class path is ignored. -verbose Shows the classes that are loaded. This option may be useful to debug class loading problems. -Xmssize -Xmxsize Sets the initial or maximum heap size. The size is a value in bytes. Add a suffix k or m for kilobytes or megabytes, for example, -Xmx10m Get More FREE Refcardz. Visit refcardz.com now! Core Seam Core CSS: Part III Hibernate Search Equinox EMF XML JSP Expression Language ALM Best Practices HTML and XHTML Available: Essential Ruby Essential MySQL JUnit and EasyMock Getting Started with MyEclipse Spring Annotations Core Java Core CSS: Part II PHP Getting Started with JPA JavaServer Faces Core CSS: Part I Struts2 Core .NET Very First Steps in Flex C# Groovy NetBeans IDE 6.1 Java Editor RSS and Atom GlassFish Application Server Silverlight 2 Visit refcardz.com for a complete listing of available Refcardz. Design Patterns Published June 2008 F RE E DZone communities deliver over 4 million pages each month to more than 1.7 million software developers, architects and decision makers. DZone offers something for everyone, including news, tutorials, cheatsheets, blogs, feature articles, source code and more. “DZone is a developer’s dream,” says PC Magazine.