0% found this document useful (0 votes)
44 views11 pages

SDA - Lab 6 - 2k22

The document provides instructions for installing Java Development Kit (JDK) 18 and Eclipse 2022. It explains how to set the environment path variable and test the JDK installation. It then demonstrates how to create and run a simple Java program in Eclipse, including making a new project, class, and using the run button. The lab task assigns students to run two sample Java programs provided and write a method to convert hours to seconds.

Uploaded by

ssss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views11 pages

SDA - Lab 6 - 2k22

The document provides instructions for installing Java Development Kit (JDK) 18 and Eclipse 2022. It explains how to set the environment path variable and test the JDK installation. It then demonstrates how to create and run a simple Java program in Eclipse, including making a new project, class, and using the run button. The lab task assigns students to run two sample Java programs provided and write a method to convert hours to seconds.

Uploaded by

ssss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Software Design and Architecture

Laboratory # 06

UET TAXILA
Engr. Sidra Shafi

CLO Learning Outcomes Assessment Item BT Level PLO


No.
1 Construct the experiments / projects Lab Task, Mid Exam,
of varying complexities. Final Exam, Quiz,
P2 3
Assignment, Semester
Project
2 Use modern tool and languages. Lab Task, Semester
P2 5
Project
3 Demonstrate an original solution of Lab Task, Semester
A2 8
problem under discussion. Project
4 Work individually as well as in teams Lab Task, Semester A2 9
Project
Introduction to Java Programming Language
Statement Purpose:
After this Lab, students will be able to understand:
• Install JDK 18
• Introduction to Java Program Structure
• Run simple Java Programs on Command Prompt and in Eclipse 2022

Tool: JDK and Eclipse

JDK INSTALLATION:
For compiling and running java programs we need to install Java Development Kit (JDK).

The JDK is a development environment for building applications and components using the Java
programming language.

The JDK includes tools for developing and testing programs written in the Java programming
language and running on the Java platform.

DOWNLOADING JDK 18:


• Go to this link and download JDK 18
https://www.oracle.com/java/technologies/javase/jdk18-archive-downloads.html

• Click on the Java exe.


After downloading double click the jdk exe icon to start installation process.

INSTALLATION STEPS:
1. Double click the jdk exe. A window will open. Click NEXT to move ahead.
2. Select the directory where you want to install this software.
3. Then click next.
4. Click Close after successfully installed message appears.
5. Now you can create, compile, and run java programs.

• Now check the location of installed Java.

3rd Semester UET TAXILA


Right click the Java Path and Copy this path as shown below.

Setting Environment Variable:


i. Go to Start and Type Environment Variables and click Open.

3rd Semester UET TAXILA


ii. Click Environment variables.

iii. Select Path under System variables. Double click this path.

3rd Semester UET TAXILA


iv. A new window will open, select new and paste the copied path. Click OK.

Test your configuration:


Go to Start, Type CMD, Click Open.
On CMD, type command java -version and press enter.

This will print out the version of the java compiler if the Path variable is set correctly or “javac is not
recognized as an internal or external command…” otherwise

3rd Semester UET TAXILA


Running Java Programs in Eclipse:
Download Eclipse and Install after selecting jdk 18 as shown below.

https://www.eclipse.org/downloads/

Select 2nd Option.

Select the Java Version and Installation folder by clicking folder on right side.

3rd Semester UET TAXILA


Accept License. Click Install. The installation will start now.

Select the check box and then click Trust Selected.

3rd Semester UET TAXILA


Now Click Launch.
Select Workspace where you want to save your Java Programs. You can change workspace later.
(File->Switch Workspace)

dependencies.

3rd Semester UET TAXILA


Create a New Project. File->New->JAVA Project.

Click Finish.

It will ask to Open Perspective. Click Open Perspective option in Next window.
Create new Class and type the above code. Click on run icon. Eclipse will show output on console.

3rd Semester UET TAXILA


Now write a program in editor and then click Run As Java Application.

3rd Semester UET TAXILA


It will show output on Console as shown below.

Lab Task Marks: 10

Task 1: Marks: 4
Run the following codes in Eclipse and observer the outputs.

Program # 1
public class Program1 {
//your program begins with a call to main()
public static void main(String[] args) {
System.out.println("Welcome to Java World!"); //println() displays the string which
is passed to it.
} }

Program # 2
class Program2 {
public static void main(String[] args) {
int a,b,c; //this statement declares three variables a, b and c.
a=2;
b=3;
c=a+b;
System.out.println("Sum of two numbers = "+c); } }

Task 2: Marks: 6
Write a method that converts hours into seconds.
Examples:
howManySeconds(2) ➞ 7200
howManySeconds(10) ➞ 36000
howManySeconds(24) ➞ 86400

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

3rd Semester UET TAXILA

You might also like