Today we shall see how to create Java Itegrated Development Environment (IDE) on your PC and write, test & run your Programs in simple steps.
Carefully read following steps and work accordingly for most easy, smooth and perfect work.
Table of Contents
Installing Java IDE on your PC/Laptop
With Java IDE you will be able to write your own programs in Java and Run them for studying and testing.
- First visit this link (https://www.oracle.com/in/java/technologies/javase-jdk15-downloads.html), scroll down at the bottom of the page and then click on Windows x64 Installer, 159.71 MB, jdk-15.0.2_windows-x64_bin.exe and download JDK on your computer. Then install it.
- After that download Eclipse IDE from this link (https://www.eclipse.org/downloads/) and install it.
- After completing above two steps, restart your computer.
- Click on the shortcut icon of Eclipse on the desktop to start the Eclipse IDE on your PC.
Create Workspace
- First of all go to desktop or any other location on your computer and right click to create a new folder.
- Give a name ‘My Java Programs’ to this folder which will serve as your workspace for your studying and testing programs in Eclipse IDE.
- Now open Eclipse IDE by double clicking on desktop shortcut icon.
- Click on Menu > Switch Workspace > Other.
- This will open a dialog box – Eclipse IDE Launcher.
- Click on ‘Browse’ button and browse your workspace folder ‘My Java Programs’ location and select it.
- Then click ‘Launch’ on Eclipse IDE Launcher Dialog box.
- This will complete first step of creating workspace to write, test and run your programs.
- All the data of your programs will be stored in this workspace.
Create your First Java Project
- Open Eclipse IDE again (if closed) by double clicking on desktop shortcut icon.
- Click on Menu > Files > Java Project
- The ‘Create a Java Project’ dialog box will appear.
- Type a name of the project in ‘Project Name’ field as ‘TestPrograms’ and press enter.
- Another dialog box of ‘New Module-Info.java’ will open.
- Click the ‘Don’t Create’ button at the bottom.
- This will complete step-2 and now you are ready for creating the classes in Java IDE.
Create Classes
- Open Eclipse IDE again (if closed) by double clicking on desktop shortcut icon.
- Click on Menu > Files > New > Class
- The ‘New Java Class’ dialog box will appear.
- Write a name of the class in ‘Name’ field and then press enter to create class.
Now Start Writing your Programs
- Now open a class by double clicking on the list of classes in ‘Package Folder’ section, on the left.
- This will open the class in a tab at the middle workspace of Eclipse IDE.
- After that start typing your programs in this workspace under respective class tab.
Tested Practice Programs of Java
Once you setup your Eclipse installation and Java IDE on your computer, you will be curious to practice different programs using Java.
For that try the following lab tested programs of Java.
Remember you have to create exactly the classes given at the beginning of each of the following programs. However, you can change the name of the classess in the programs as per your choice also.
Welcome to Java
class Welcome {
public static void main(String args[])
{
System.out.println("Welcome to Java!");
}
}
Addition of two numbers
class Addition
{
public static void main(String[] args) // the method
{
int a=10; // first variable declared
int b=30; // first variable declared
int c=a+b; // first variable declared
System.out.println(c); // print the output
}
}
Incrementing Variable Value
class Increment
{
public static void main(String[] args)
{
int a = 5;
int b = ++a; // the operator appears before the operand
System.out.println(b);
System.out.println(a);
}
}
Decrementing Variable Value
class Decrement {
public static void main(String[] args)
{
int a = 5;
int b = a++; // the operator appears after the operand
System.out.println(b);
System.out.println(a);
}
}
How to get user input in a program?
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
Scanner readme = new Scanner(System.in);
System.out.println("Enter two numbers & press enter each time:");
//two variables to hold numbers
int a, b, c;
a = readme.nextInt();
b = readme.nextInt();
c = a + b;
System.out.println("Total = " + c);
}
}
If you liked this post, please comment below.