You are on page 1of 10

CSE 1001: Introduction to Computer Programming

Eclipse IDE & Programming Assignment-I


(Java Programming Environment Setup)

Introduction

This lab assignment is intended to familiarize you with Eclipse IDE and the process of editing,
compiling and executing a simple Java Program. This lab has been designed with a specific set of
steps for you to follow. If you have any questions or run into any trouble, please let your instructor
know.

What is Eclipse?

Eclipse is an integrated development environment (IDE), which combines a text editor, a compiler,
a virtual machine, and a number of additional tools into one platform. In the context of computing,
Eclipse is used for developing applications using the Java programming language and other
programming languages such as C/C++, Python, PERL, Ruby etc.

Programming Environment Setup


1. Workspace selection
A workspace is the repository for all of the files that make up your projects and all of your settings.

Step 1: Create your workspace folder under home directory of Ubuntu OS.

The folder name should be <Your Regd. No>

Example: (1641012001)

Step 2: Open Eclipse, go to File->Switch Workspace->Other

Enter (or Browse to) the workspace folder that you created)
Eclipse: A First Look
Find the Eclipse shortcut on the desktop and double-click on it to start Eclipse. You will be
presented with the following window.
This is an introductory screen that provides several links to more information about Eclipse. Now,
move the mouse to Workbench icon (the rounded arrow on the right of the window) and click on it.
This will take you to the Java perspective shown below.

The Eclipse window is always organized according to a perspective. The current perspective
determines the panels (views and editors) that are displayed in the Eclipse window. The default
perspective when Eclipse is started for the first time is called the Java perspective which is where
you will do all of your programming work for this class.

For now, just take a look around the current window: note the menubar at the top with a variety of
menus (File, Edit, Help, etc.), the toolbar below it, and the various panels in the Java perspective
(Package Explorer/Hierarchy, Outline, Problems/Javadoc/Declaration). This is the typical structure
of most Eclipse perspectives.
2. Creating a new java project
Let's start by creating a new Java project. This is always the first step in creating a new Java
program. A project is like a folder collecting the files for a given program (or lab assignment).

Select File->New->Java Project.

This will open the New Java Project dialog.


Type Lab1 in the Project name box. Then click on the Finish button at the bottom. This will
create the new Lab1 project.

Now you can see a folder called Lab1 listed in the "Package Explorer." This folder represents your
new project. Now it is an empty project.

The blank area in the center is meant for the editor which will appear when we start editing our
program. Note also that the Lab1 project you just created is listed in the Package Explorer panel on
the left.
3. Create a new Java class

Go to File->New ->Class

This will open the New Java Class dialog.

Type Welcome in the Name box. Select the checkbox next to public static void main(String[]
args) to make sure a main program skeleton is created. Finally click on the Finish button. Here is
what the Eclipse window will look like, note that the editor panel now displays the skeleton of our
new java program.
4. Editing

Edit the program so that it looks exactly as the following

public class Welcome


{
public static void main(String[] args)
{
System.out.println("Welcome to ITER");
}
}

Then click on the Save button at the top left of the window to save your program.
5. Compiling and Running a Program

Now it's time to run your first program. Note that before running the program it is necessary to
compile it. However, by default, Eclipse compiles your program after every save. So the program is
already compiled and you can execute it. If you made any Java syntax mistakes in typing the
program, Eclipse will list the errors in the Problems tab under the editor window. Fix them and save
the program again.

To run the program, select Run->Run.

After a short time, the program will start and a new tab labelled Console will appear in the bottom
pane. This is the space where you will be able to interact with your program, i.e., this is where the
output of the program will be displayed and where you will be expected to type any inputs your
program needs.
Programming Assignment-I

1. Write a java program to display following messages.


Hello World!
Hello Again
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.

2. Write a java program that displays your name and address on the screen as if it were a letter.
Your output should look something like that below.

+---------------------------------------------------------+
| #### |
| #### |
| #### |
| |
| |
| Biswanath Dash |
| H.N:109, Baramunda |
| Bhubaneswar |
| |
+-------------------------------------------------------------------------------------------------------+

3. Write a java program to display your initials on the screen in block letters as shown.
For example the name Tapan Kumar

TTTTTTTT K K
T K K
T K K
T K
T K K
T K K
T K K

4. Write a java program to print an equilateral triangle using star ' * '.

*
**
***
****
*****
******

You might also like