By Steve Holzner
Price: $44.95 USD
£31.95 GBP
Cover | Table of Contents | Colophon
javac, Eclipse can make life easier for you. In
fact, Eclipse's Integrated Development Environment
(IDE) makes the development process as close to fun as it can get:
the first time that Java programmers fire up Eclipse and start to use
it, they often find themselves thinking, This is
great!
http://www.eclipse.org. Just click the
Downloads link located on the
left side of that page.http://www.eclipse.org/downloads/index.php.
The download page appears in Figure 1-1.
javac, Eclipse can make life easier for you. In
fact, Eclipse's Integrated Development Environment
(IDE) makes the development process as close to fun as it can get:
the first time that Java programmers fire up Eclipse and start to use
it, they often find themselves thinking, This is
great!
http://www.eclipse.org. Just click the
Downloads link located on the
left side of that page.http://www.eclipse.org/downloads/index.php.
The download page appears in Figure 1-1.
http://www.eclipse.org; the technical
articles at www.eclipse.org/articles/index.html; the
newsgroups at http://www.eclipse.org/newsgroups/index.html
eclipse -data
newWorkSpacePath -showLocation on the command line. This
starts Eclipse with the workspace given by
newWorkSpacePath (the
-showLocation option makes windows show their
location, making it easy to remember where you are if you launch
multiple windows). You would use this technique if you want to
partition projects into different workspaces to keep them separate.public class FirstApp
{
public static void main(String[] args)
{
System.out.println("Stay cool.");
}
}
Java
in the left pane and Java
Project in the right pane. Click Next, and in the
next dialog name the project FirstApp, as shown in
Figure 1-6.
public class FirstApp
{
public static void main(String[] args)
{
System.out.println("Stay cool.");
}
}public, private, or
protected; you
can
make the class abstract or
final; you can specify the
new
class's superclass
(java.lang.Object is the default); and you can
specify which, if any, interfaces it implements. Class creation is
covered in more detail in Chapter 3.org.cookbook.ch01. Enter the name of this new
class, FirstApp, in the Name box and the name of a
new package for this class, org.cookbook.ch01, in
the Package box. Note in particular that under the question in this
dialog "Which method stubs would you like to
create?" that we're leaving the
checkbox marked "public static void main(String[]
args)" checked. Doing so means that Eclipse will
create an empty main method automatically. Click
Finish to accept the other defaults.public class FirstApp
{
public static void main(String[] args)
{
System.out.println("Stay cool.");
}
}System. in the
main method of the FirstApp
project, then pause. Code assist displays the classes and methods in
the System namespace, as shown in Figure 1-11.
out in the code assist list so that
code assist inserts that member into your code, insert a period so
that the phrase now reads System.out., and pause
again. Code assist now displays the methods of the
out class. Double-click the code assist suggestion
println(String arg0), and code assist inserts the
following code into the main method:public class FirstApp
{
public static void main(String[] args)
{
System.out.println( )
}
}Stay
cool.. Note that code assist adds
the closing quotation mark automatically as you type:public class FirstApp
{
public static void main(String[] args)
{
System.out.println("Stay cool.")
}
}Stay cool., appearing in the Console
view at the bottom.
ScrapPage, in the File box,
and click Finish. The new scrapbook page is stored in the Package
Explorer as ScrapPage.jpage, as shown in Figure 1-14.
main method of our example, you have to
qualify its name with the name of the package it's
in:
String[] args = {};
org.cookbook.ch01.FirstApp.main(args);
println statements.public class FirstApp {
public static void main(String[] args) {
Date date = new Date( );
stayCoolText = "Stay cool.";
System.out.println(stayCoolText + " Date now is " + date.toString( ));
}
}
Date class can't be resolved, as
shown in Figure 1-16.
import 'java.util.Date'
suggestion to import the Date class so that it can
be resolved.
Delete. Eclipse will display the Confirm
Project Delete dialog box, as shown in Figure 1-20.