Introduction to Eclipse

Download Report

Transcript Introduction to Eclipse

Introduction to Java Lab
CS110A – Lab
Section 004
Instructor: Duo Wei
Outline



General Information for Java Lab
Introduction to Eclipse
First program– “Hello World!”
General Information





Instructor: Duo Wei
Office: GITC 4402
Office hours: Friday 5-6pm
Email: [email protected]
For more information, please visit my
website:
http://web.njit.edu/~dw59
What is Eclipse?



An Integrated Development Environment
Useful tool for Java program development
Provides many features to ease Java
programming (and others, e.g. C/C++)




Editor
Debugger
Source Control
…
Getting Eclipse

At the CS labs…


It’s already installed
At home…

Download the latest version at:

http://www.eclipse.org/
Installing and Running Eclipse

Installation is very simple


Just unpack the downloaded package
Running Eclipse




Then click eclipse.exe (under Windows)
Run eclipse (under Linux)
Eclipse will start running if all the prerequisites are
met
Demo: Run Eclipse
Setting up your Workspace

Workspace is where your projects and
programs are stored.




Usually some directory in the file system
The workspace is set when Eclipse starts
My suggestion: create a file in the local
directory.
Eg. My Document  create your file (Duo)
Creating Java Projects

Demo: Creating a project for
assignment1 in the workspace
Creating Java Packages


A Package in Java is a group of classes which are
often closely or logically related in some way
Package corresponds to the directory hierarchy
in the file system.



course.cs110.assignment1
Organizing source files into different packages is
a good programming style.
Since this is the first class you do not need to
create package. Create class directly, see next
slide …
Adding Java Classes


Class is the basic compilation unit in
Java.
Demo: Creating the Employee class of
assignment1
Running the code




Currently, no implementation is provided in
the given files. You are expected to fill the
implementation details.
We need a class which has a main() method
as the entrance for execution
Run (Menu)  Run as  find your java file
click
Review what we learned…

Setting up your Workspace
Creating Java Projects

Creating Java Packages (not necessary)



Adding Java Classes
Running the code
First Java program-HelloWorld

public class HelloWorld{
public static void main(String args[]){
System.out.println(“Hello World!”);
}
}
Now, run the program, and see what is the
output?
Questions?