Java Lab Mannual
Java Lab Mannual
LAB MANUAL
II CSE A & B
II Year / IV Semester
LIST OF EXPERIMENTS
3. Program to implement different types of inheritances like multiple, Multilevel and hybrid.
10. Program to design an event handling event for simulating a simple calculator.
3 FUNCTION OVERLOADING
A) SINGLE INHERITANCE
B) MULTILEVEL INHERITANCE
4 C) HIERARCHICAL INHERITANCE
D) HYBRID INHERITANCE
E) MULTIPLE INHERITANCE
5 ABSTRACT CLASS
6 I/O STREAMS
7 TYPE CONVERSION
8
EXCEPTION HANDLING – DIVIDE BY ZERO
9 EVENT HANDLING- CALCULATOR
10 JDBC
AIM:
To write a Java program to implement a simple student class without access specifiers.
ALGORITHM:
1. Start the program.
2. Create a class Student with two data members with default access specifier.
3. Create another class named J2aSimpleClass.
4. Create an object of type student inside the main() of J2aSimpleClass.
5. Assign values to the data members of student class inside the J2aSimpleClass.
6. Print the two data members of student class.
7. Stop the program
SOURCE CODE
package javaapplication1;
/**
*
* @author
MitStaff */
//if access specifiers are not specified then the class members are Visible to the package, the default.
//No modifiers are needed.
class student
{
int regno;
String name;
}
RESULT
Thus the Java program to implement a simple student class without access specifiers
have been completed successfully and the output is verified.
1.(B)(i) CLASSES AND OBJECTS - SIMPLE STUDENT CLASS WITH ACCESS SPECIFIERS
AIM:
To write a Java program to implement a simple student class with access specifiers.
ALGORITHM:
1. Start the program.
2. Create a class Student with two data members with private access specifier.
3. Create two methods to get values for data members and to display the data member
values .
4. Create an object of type student inside the main() of J2bSimpleClass.
5. Assign values to the data members of student class through getdata() function.
6. Print the two data members of student class using showdata() funtion.
7. Stop the program
SOURCE CODE
package javaapplication2;
/**
*
* @author
MitStaff */
//Note: private - Can access inside the class (Not access by object, Not access by derived class)
import java.util.Scanner;
class student
{
private int regno;
private String name;
void getdata()
{
Scanner in = new Scanner(System.in);
System.out.println ("Enter the Register Number");
regno = in.nextInt();
System.out.println ("Enter the Name");
name = in.next();
}
void showdata()
{
System.out.println("Reg No " + regno);
System.out.println("Name " + name);
}
}
OUTPUT
RESULT
Thus the Java program to implement a simple student class with access specifiers have been
completed successfully and the output is verified.
1.(B)(ii) CLASSES AND OBJECTS - SIMPLE STUDENT CLASS WITH ACCESS SPECIFIERS
AIM:
To write a Java program to implement a simple student class with access specifiers.
ALGORITHM:
1. Start the program.
2. Create a class student with its data member and member function
3. Get marks and regno as Integer data type and name as String data type from user using
getdata().
4. Calculate the result in calculation().
5. Display Student details using show() function.
6. Create a main class J2cSimpleClass and create instances of student class.
7. Using the instance call the above mentioned methods and find out whether the result of
an student is PASS or FAIL.
8. Stop the program
SOURCE CODE
package javaapplication3;
/**
*
* @author
MitStaff */
import java.util.Scanner;
class student
{
private String name,result;
private int regno,m1,m2,m3,total;
private float percentage;
void getdata()
{
Scanner in = new Scanner(System.in);
void calculation()
{
total=m1+m2+m3;
percentage=(total)/3;
if(m1>=50 && m2>=50 && m3>=50)
{
result="PASS";
}
else
{
result="FAIL";
}
}
void show()
{
System.out.println ("\t\t\tStudent Details");
System.out.println ("Name = "+name);
System.out.println ("Register Number = "+regno);
System.out.println ("Marks of 1st Subject = "+m1);
System.out.println ("Marks of 2nd Subject = "+m2);
System.out.println ("Marks of 3rd Subject = "+m3);
System.out.println ("Total Marks = "+total);
System.out.println ("Result = "+result);
System.out.println ("Percentage = "+percentage+"%");
}
}
class J2cSimpleClass
{
public static void main(String[] args)
{
student s=new student();
System.out.println ("\t\t\tStudent Information System");
s.getdata();
s.calculation();
s.show();
}
}
OUTPUT
RESULT
Thus the Java program to implement a simple student class with access specifiers have been
completed successfully and the output is verified.
2(A) CONSTRUCTOR AND DESTRUCTOR –Types of Constructors
AIM:
ALGORITHM:
1. Start the program.
2. Declare the class name as Shape with data members and member functions.
3. The default constructor Shape initializes the data members with default values.
4. The member function displayDimension() displays with the initialized values.
5. Create a main class ConstAndDest.
6. Create 4 instances (nodim,line,rectangle1,cuboid,rectangle2)of Shape class.
7. Objects nodim,line,rectangle1 and cuboid invokes default ,one ,two, three parameterized
constructors respectively.
8. Object rectangle2 invokes copy constructor to copy the data member values of object
rectangle1.
9. Call the displayDimension() method with objects, which displays the assigned values.
10. Stop the program
SOURCE CODE
package javaapplication5;
/**
*
* @author
MitStaff */
// PROGRAM TO IMPLEMENT DEFAULT, PARAMETERISED & COPY CONSTRUCTOR
class Shape
{
//variables declared within class are INSTANCE VARIABLES
private int length;
private int breadth;
private int height;
//DEFAULT CONSTRUCTOR
Shape()
{
System.out.println("\n No-Argument Constructor (i.e.) Default Constructor is invoked");
}
//here length denotes LOCAL VARIABLE AND this.length denotes INSTANCE VARIABLE
System.out.println("\n three-Argument Constructor is invoked"); this.length=length;
this.breadth=breadth;
this.height=height;
}
//COPY CONSTRUCTOR
Shape(Shape s)
{
System.out.println("\n Copy Constructor is invoked");
length=s.length;
breadth=s.breadth;
height=s.height;
}
OUTPUT
RESULT
Thus the constructors and destructors program executed and verified successfully.
2(B) CONSTRUCTOR AND DESTRUCTOR – with Array of Objects
AIM:
To write a Java program to demonstrate Constructor and Destructor with Array of Objects.
ALGORITHM:
11. Start the program.
12. Declare the class name as Student with data members and member functions.
13. The default constructor Student initializes the data members with end user values.
14. The member function showData() displays with the initialized values.
15. Create a main class CandDwithAoO.
16. Create array of instances variables of Student class.
17. For created references allocate memory using new keyword in a for loop, which
automatically initializes the data members.
18. Call the showData () method with objects, which displays the assigned values.
19. Stop the program
SOURCE CODE
package javaapplication4;
import java.util.Scanner;
class Student
{
String name;
int rollno;
Student()
{
Scanner sin = new Scanner(System.in);
System.out.println("Enter Name : ");
name=sin.next();
System.out.println("Enter Roll No : ");
rollno=sin.nextInt();
}
void showData()
{
System.out.println("Student name is "+name);
System.out.println("Student rollno is "+rollno);
}
}
for(i=0;i<count;i++)
{
System.out.println("ENTER DETAILS FOR
STUDENT"+(i+1)); Students[i]=new Student();
}
OUTPUT
RESULT
Thus the constructors and destructors program executed and verified successfully.
3 FUNCTION OVERLOADING
AIM:
ALGORITHM:
SOURCE CODE
package javaapplication6;
import java.util.Scanner;
switch(ch)
{
case 1:
System.out.print("Enter the side of the cube:");
a=sin.nextInt();
v.calculate(a);
break;
case 2:
System.out.print("Enter the radius of the cylinder:");
r=sin.nextFloat();
System.out.print("Enter the height of the cylinder:");
h=(int) sin.nextFloat();
v.calculate(r,h);
break;
case 3:
System.out.print("Enter the length of base of the
pyramid:"); l=sin.nextInt();
System.out.print("Enter the breadth of base of the pyramid:");
b=sin.nextInt();
ba=l*b;
System.out.print("Enter the height of the
pyramid:"); //h=(int)sin.next();
//ERROR : INCOMPATIBLE TYPES - string cannot be converted to integer
h=Integer.parseInt(sin.next());
//if no Wrapper Class used then ERROR : INCOMPATIBLE TYPES - string
cannot //be converted to integer
v.calculate(ba,h);
break;
case 4:
System.exit(0);
break;
default:
System.out.println("\n\tINCORRECT CHOICE\nTRY AGAIN");
}
}while(ch!=4);
}
}
OUTPUT
RESULT
AIM:
To write a Java program to implement single inheritance using simple methods.
ALGORITHM:
SOURCE CODE
package exp4a;
class A {
class B extends A {
}
OUTPUT
RESULT
Thus the program for single inheritance executed and verified successfully.
4(B) STUDENT INFORMATION SYSTEM USING SINGLE INHERITANCE
AIM:
To write a Java program to implement Student Information system using single
inheritance concept.
ALGORITHM:
SOURCE CODE
package exp4b;
// private - Can access in the current class (Not object, Not derived class)
// protected - Can access in the current class, derived class and object (not other package)
// public - Can access in the current class, derived class, object and other package
// Single Inheritance: A -> B
// extends - Inherits from base class
import java.util.Scanner;
class student {
protected int regno, m1, m2, m3, m4, m5; //Data Member Declaration
protected String name, dept;
System.out.println("Enter mark1");
m1 = in.nextInt();
System.out.println("Enter mark2");
m2 = in.nextInt();
System.out.println("Enter mark3");
m3 = in.nextInt();
System.out.println("Enter mark4");
m4 = in.nextInt();
System.out.println("Enter mark5");
m5 = in.nextInt();
}
}
class exam extends student //Deriving new class from base class
{
void calculation() {
total = m1 + m2 + m3 + m4 + m5;
average = (total) / 5;
if (m1 >= 50 && m2 >= 50 && m3 >= 50 && m4 >= 50 && m5 >= 50) {
result = "PASS";
} else {
result = "FAIL";
}
}
void show() {
System.out.println("\t\t\tStudent Details");
System.out.println("Name = " + name);
System.out.println("Register Number = " + regno);
System.out.println("Marks of 1st Subject = " + m1);
System.out.println("Marks of 2nd Subject = " + m2);
System.out.println("Marks of 3rd Subject = " + m3);
System.out.println("Marks of 4th Subject = " + m4);
System.out.println("Marks of 5th Subject = " + m5);
System.out.println("Total Marks = " + total);
System.out.println("Result = " + result);
System.out.println("Percentage = " + average + "%");
}
}
class J3bInheritance {
ex.calculation();
ex.show();
}
}
OUTPUT
RESULT
Thus the program for Student Information System using single inheritance executed
and verified successfully.
4(C) STUDENT INFORMATION SYTEM USING MULTILEVEL INHERITANCE
AIM:
ALGORITHM:
SOURCE CODE
import java.util.Scanner;
class student {
class marks extends student //Deriving new class from base class
{
protected int m1, m2, m3, m4, m5; //Data Member Declaration
System.out.println("Enter mark1");
m1 = in.nextInt();
System.out.println("Enter mark2");
m2 = in.nextInt();
System.out.println("Enter mark3");
m3 = in.nextInt();
System.out.println("Enter mark4");
m4 = in.nextInt();
System.out.println("Enter mark5");
m5 = in.nextInt();
}
}
class result extends marks //Deriving new class from base class
{
void calculation() {
total = m1 + m2 + m3 + m4 + m5;
average = (total) / 5;
if (m1 >= 50 && m2 >= 50 && m3 >= 50 && m4 >= 50 && m5 >= 50) {
result = "PASS";
} else {
result = "FAIL";
}
}
void show() {
System.out.println("\t\t\tStudent Details");
System.out.println("Name = " + name);
System.out.println("Register Number = " + regno);
System.out.println("Marks of 1st Subject = " + m1);
System.out.println("Marks of 2nd Subject = " + m2);
System.out.println("Marks of 3rd Subject = " + m3);
}
}
class J3cMultipleLevelInheritance {
OUTPUT
RESULT
Thus the Student Information System using multilevel inheritance has been executed and
verified successfully.
4(D) HIERARCHICAL INHERITANCE
AIM:
To write a Java program to implement Hierarchical inheritance.
ALGORITHM:
SOURCE CODE
class A {
public void methodA() {
System.out.println("method of Class A");
}
}
class B extends A
{
public void methodB()
{
System.out.println("method of Class B");
}
}
class C extends A
{
public void methodC()
{
System.out.println("method of Class C");
}
}
class D extends A
{
public void methodD()
{
System.out.println("method of Class D");
}
}
class MyClass
{
public void methodB()
{
System.out.println("method of Class B");
}
}
public static void main(String args[])
{
B obj1 = new B();
C obj2 = new C();
D obj3 = new D();
obj1.methodA();
obj2.methodA();
obj3.methodA();
}
}
OUTPUT
RESULT
Thus the program for hierarchical inheritance executed and verified successfully
4(D) HYBRID INHERITANCE
AIM:
To write a java program to implement hybrid inheritance
ALGORITHM
SOURCE CODE
interface A
{
public void methodA();
}
interface B extends A
{
public void methodB();
}
interface C extends A
{
public void methodC();
}
class D implements B, C
{
OUTPUT
RESULT
Thus the program to implement hybrid inheritance executed and verified successfully.
4(E) MULTIPLE INHERITANCE
AIM:
To write a java program to implement multiple inheritance
ALGORITHM
SOURCE CODE
interface Printable {
void print();
}
interface Showable {
void show();
}
RESULT
Thus the program to implement multiple inheritance executed and verified successfully.
5 ABSTRACT CLASS
AIM:
ALGORITHM:
SOURCE CODE
void display()
{
System.out.println("You are using circle class");
}
void display()
{
System.out.println("You are using rectangle class");
}
void display()
{
System.out.println("You are using triangle class");
}
class ShapeAbstract
{
s = new Rectangle();
s.display();
s = new Triangle();
s.display();
}
}
OUTPUT
RESULT
Thus the use of abstract class program executed and verified successfully
6 I/O STREAMS
AIM:
To write a java program to demonstrate simple i/o streams and its methods
ALGORITHM:
SOURCE CODE
import java.io.*;
class stream1
{
public static void main(String args[]) throws IOException
{
// create a BufferedReader using System.in
BufferedReaderbr = new BufferedReader(new InputStreamReader(System.in));
String str[] = new String[100];
System.out.println("Enter lines of text.");
System.out.println("Enter 'stop' to quit.");
for (int i = 0; i< 100; i++)
{
str[i] = br.readLine();
if (str[i].equals("stop"))
{
break;
}
}
System.out.println("\nHere is your file:"); // display the lines
for (int i = 0; i< 100; i++)
{
if (str[i].equals("stop"))
{
break;
}
System.out.println(str[i]);
}
}
}
OUTPUT
RESULT
Thus the i/o stream demonstration program executed and verified successfully.
7 TYPE CONVERSION
AIM:
ALGORITHM:
SOURCE CODE
class type1 {
int x = Integer.parseInt("9");
double c = Double.parseDouble("5");
int b = Integer.parseInt("444", 10); // 10 indicates decimal
int b1 = Integer.parseInt("444", 16); // 16 indicates hexa-decimal
System.out.println(c);
System.out.println(b);
System.out.println(b1);
OUTPUT
RESULT
AIM:
ALGORITHM:
SOURCE CODE
classDivNumbers
{
public void division(int num1, int num2)
{
int result;
int[] data = {1,2,3};
try
{
result = num1 / num2;
System.out.println("Result:"+result);
//System.out.println(data[5]);
}
catch (ArithmeticException e)
{
System.out.println("Exception: "+ e);
}
catch(Exception e)
{
System.out.println("Exception:" + e);
}
finally //Optional block
{
System.out.println("Finally");
}
System.out.println("End");
}
}
public class J6aException
{
public static void main(String args[])
{
DivNumbers d = new DivNumbers();
d.division(25, 5);
d.division(25, 0);
}
}
OUTPUT
RESULT:
Thus the exception handling program executed and verified successfully.
9 EVENT HANDLING- CALCULATOR
AIM:
To write a java program to implement event handling event for simulating a simple
calculator.
ALGORITHM:
CODING:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
private JTextFieldtextfield;
int result = 0;
public Calc()
{
String[] numbers = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
buttonPanel.add(button);
String[] opOrder = {"+", "-", "*", "/", "AC", "sin", "cos", "log", "tan", "1/x", "x^y", "="};
button.addActionListener(operatorListener);
panel.add(button);
if (e.getActionCommand().equals("sin"))
{
textfield.setText("" + Math.sin(val));
}
else if (e.getActionCommand().equals("cos"))
{
textfield.setText("" + Math.cos(val));
}
else if (e.getActionCommand().equals("log"))
{
textfield.setText("" + Math.log(val));
}
else if (e.getActionCommand().equals("tan"))
{
textfield.setText("" + Math.tan(val));
}
else if (e.getActionCommand().equals("1/x"))
{
textfield.setText("" + 1.0 / val);
}
else if (e.getActionCommand().equals("AC"))
{
textfield.setText("0");
result = 0;
}
else
{
if (prevOp.equals("="))
{
result = val;
}
else if (prevOp.equals("+"))
{
result = result + val;
}
else if (prevOp.equals("-"))
{
result = result - val;
}
else if (prevOp.equals("*"))
{
result = result * val;
}
else if (prevOp.equals("/"))
{
result = result / val;
}
else if (prevOp.equals("x^y"))
{
int k = 1;
for (int i = 1; i<= val; i++)
{
k = k * result;
}
result = k;
}
prevOp = e.getActionCommand();
textfield.setText("" + result);
resultshown = true;
}
}
}
class NumberListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String digit = event.getActionCommand();
if (resultshown)
{
textfield.setText(digit);
resultshown = false;
}
else
{
textfield.setText(textfield.getText() + digit);
}
}
}
}
class Calculator
{
public static void main(String[] args)
{
Calc cal = new Calc();
cal.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cal.setVisible(true);
}
}
OUTPUT
RESULT
AIM:
ALGORITHM:
1. Create a class StudentSwingJdbc which extends the class JFrame and implements the
ActionListener.
2. Create the panel using JPanel.
3. Use textboxes and labels for rollno, name,department, mark1, mark2, mark3.
4. Add the buttons „Save‟ and „Exit‟.
5. Use the JDBC database connection in the AddStudent() method to add the new student
details by using insert command.
6. Check if the marks are greater than 50 and if it is true, print the result as “PASS” and if
it isfalse, print the result as “FAIL”.
7. Create the object for the class in the main() method.
8. Now compile and run the program to see the result.
CODING:
importjava.awt.*;
importjavax.swing.*;
importjava.awt.event.*;
importjava.sql.*;
StudentSwingJDBC()
{
super("StudentSwingJDBC");
JPanel panel = new JPanel(new GridLayout(10, 2));
lblRollno= new JLabel("RollNo");
panel.add(lblRollno);
txtRollno= new JTextField();
panel.add(txtRollno);
add(panel);
setSize(500, 400);
this.setVisible(true);
OUTPUT
RESULT
Thus the java database connectivity program executed and verified successfully.
14 REMOTE METHOD INVOCATION
AIM:
To write a java program to design and implement RMI
ALGORITHM:
CODING:
//Fact Interface
importjava.rmi.*;
importjava.rmi.server.*;
public interface FactInterface extends Remote
{
publicintfact(int n) throws RemoteException;
}
//Fact Implementation
importjava.rmi.*;
importjava.rmi.server.*;
public class FactImplementation extends UnicastRemoteObject
implements FactInterface
{
Public FactImplementation() throws RemoteException { }
public int fact(int n) throws RemoteException
{
int f = 1;
for(inti = 1; i<= n; i++)
{
f = f * i;
}
return f;
}
}
//RMI Server
importjava.rmi.*;
import java.net.*;
public class RmiServer
{
public static void main(String args[]) throws RemoteException
{
try
{
FactImplementation fi = new FactImplementation();
Naming.rebind("Server", fi);
System.out.println("Server ready");
}
catch(Exception e)
{
System.out.println("Exception:" + e);
}
}
}
//RMI client
importjava.rmi.*;
import java.io.*;
public class RmiClient
{
public static void main(String args[]) throws RemoteException
{
try
{
BufferedReaderbr = new BufferedReader(new
InputStreamReader(System.in)); System.out.println("Enter the server name
or ip address");
String url = br.readLine();
String host="rmi://" + url + "/server"; FactInterface
serv = (FactInterface) Naming.lookup(host);
System.out.println("Enter a number:"); int n =
Integer.parseInt(br.readLine());
int fact = serv.fact(n);
System.out.println("Factorial of " + n + " is " + fact);}
catch(Exception e)
{
System.out.println("Error " + e);
}
}
}
OUTPUT
RESULT
Thus the RMI using factorial method program executed and verified successfully.
15 NETWORKING – TCP ONE WAY COMMUNICATION
AIM:
ALGORITHM:
Server Program:
1. Start.
2. Import the java.net and java.io packages.
3. Declare a new class called “TcpOneWayChatServer”.
4. Within class “TcpOneWayChatServer”, create a ServerSocket object
called “ss” with the port number 8000.
5. Create a Socket object called “s” by using the accept() method, which
listens for a connection to be made to this server socket and accepts it.
6. Create a new BufferedReader object, which acts as an input stream to
the server from the client.
7. Create a new PrintStream object, which acts as an output stream to the client from
the server.
8. Display the message “Server ready...” on the server window.
9. Repeat the following steps:
i. Prompt for the message to be sent from server to client.
ii. Read in the message to be sent from the user.
iii. Send the message to the client using the PrintStream object.
iv. If the message equals the string “end”, then close the input and
output streams and exit the loop.
10. Stop
Client Program:
1. Start.
2. Import the java.net, java.io, and java.util packages.
3. Create a new class called “TcpOneWayClient”.
4. Inside “TcpOneWayClient”, create a new Socket object called “s” with port number
8000.
5. Create a new BufferedReader object which acts as the input stream to the client
from the server.
6. Repeat the following steps:
i. Read in the input from the server to the client using the BufferedReader object.
ii. Display the message received.
iii. If the string received equals “end”, then close the input and output streams
and exit the loop.
7. Stop.
CODING:
//TcpOneWayChatServer
import java.io.*;
import java.net.*;
class TcpOneWayChatServer
{
public static void main(String a[])throws
IOException {
ServerSocket ss = new ServerSocket(8000);
Socket s=ss.accept();
//TcpOneWayChatClient
import java.io.*;
import java.net.*;
class TcpOneWayChatClient
{
public static void main(String args[])throws
IOException {
Socket c = new Socket("localhost", 8000);
BufferedReadersocIn=new BufferedReader(new
InputStreamReader(c.getInputStream()));
String str;
while(true)
{
str = socIn.readLine();
System.out.println("Message Received: " + str);
}
}
}
OUTPUT
RESULT
Thus the one way communication using TCP program executed and verified successfully.
16 Build GUI-Based Application Development Using JavaFX
AIM:
ALGORITHM:
1. Start.
2. Import necessary JavaFX packages for creating the GUI layout and handling events.
3. Define a class HelloApplication extending Application and override the start() method.
4. Set up a GridPane layout and configure padding, spacing, and alignment.
5. Create input fields for "Username" and "Password" with labels and placeholders.
6. Add buttons for "Sign In", "Reset", and "Sign Up" along with a "Remember Me"
checkbox and a "Forgot Password?" hyperlink.
7. Implement event handling:
o Sign In button checks hardcoded credentials.
o Reset button clears all fields.
o Forgot Password link simulates sending reset instructions.
o Sign Up button redirects (placeholder action).
8. Display success or failure messages based on user input.
9. Set the scene, size it to 400x300 pixels, and show the window.
10. Stop.
CODING:
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Sign In");
// Layout setup
GridPane grid = new GridPane();
grid.setPadding(new Insets(15, 15, 15, 15));
grid.setVgap(10);
grid.setHgap(10);
grid.setAlignment(Pos.CENTER);
// Remember Me Checkbox
CheckBoxrememberMe = new CheckBox("Remember Me");
// Status/Message Label
Label messageLabel = new Label();
NOTE:
SETUP PROCEDURE
1. Install JDK and JavaFX SDK:
o Download and install the JDK from Oracle or use OpenJDK.
o Download the JavaFX SDK from https://openjfx.io and extract it to a known
location.
2. Set Up the IDE:
o Use an IDE like IntelliJ IDEA, Eclipse, or NetBeans.
o Add JavaFX SDK .jar files to your project’s library or classpath.
o Add VM options:
--module-path "path_to_javafx/lib" --add-modules javafx.controls,javafx.fxml
3. Write, Compile, and Run:
o Copy the provided Java code into a file named HelloApplication.java.
o Compile with:
javac --module-path "path_to_javafx/lib" --add-modules javafx.controls
HelloApplication.java
o Run with:
java --module-path "path_to_javafx/lib" --add-modules javafx.controls
HelloApplication
OUTPUT:
RESULT:
Thus, the Sign In GUI-based application using JavaFX was successfully implemented
and verified.