0% found this document useful (0 votes)
12 views

Java Final MMMM

Project

Uploaded by

vikram96kmaratha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Java Final MMMM

Project

Uploaded by

vikram96kmaratha
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

INDEX

SR NO. CONTENT PAGE NO.

1 Acknowledgment 1

2 Introduction 2

3 Requirement analysis 4

4 Class diagram 5

5 Use case diagram 6

6 ER diagram 10

7 Input 11

8 Output 24

9 Conclusion 25

10 Reference 26
ACKNOWLEDGMENT

I am sincerely grateful to Loknete Gopinathji Munde Institute of Engineering Education


& Research for providing me with the opportunity to undertake this micro project. My
heartfelt thanks to Dr. K.V. Chandratre for his invaluable encouragement and support
throughout this endeavor.

I extend my gratitude to Mr. Vijay Bodake, Head of Computer Diploma Engineering, for his
guidance and insights that greatly contributed to the success of this project. Special thanks to
Mr.Bodake sir for her continuous support and expertise in Java Pragramming.

Furthermore, I would like to express my appreciation to all the faculty members and staff of
the computer engineering department for their assistance and cooperation. Their expertise and
guidance were instrumental in completing this project successfully.

Lastly, I want to extend my thanks to my friends and family for their unwavering support and
understanding during this academic journey. Their encouragement and belief in me have been
invaluable.
INTRODUCTION

Bharat Sanchar Nigam Limited (BSNL) is an esteemed Government organization,


which is having a very big network, connecting all over India through Telecommunications. It
has also launched Mobile Services, which makes the communication easier. Its various
services include India Telephone Card (ITC), CallNow, CellOne, Excel, Bfone, tarang,
Webfone, Sanchar Net, and Student Power Offer, which are very successful in market and are
getting eccentric support of the people.
The BSNL Central Exchange in Visakhapatnam is known as DoTSoft (Department of
Telecommunications) and is connected to more than 200 sub exchanges known as RLUs. It is
highly equipped with the Servers such as Oracle Central Server, and NMS Server for FTP, and
nearly 10 computers for office work. Recently Oracle server under LINUX has been launched.
Nearly 400 Computers are connected to this exchange with 64 Kbps leased lines.
The BSNL Central Exchange (DoTSoft) in Visakhapatnam is connected to more than 200 Sub
Exchanges (Clients) with 64 Kbps Leased Lines. Entire BSNL is using Oracle Runtime
Reports (.fmx extension) in their day-to-day operations. They are having a separate Oracle
Server and NMS Server (FTP) for operations. The DoTSoft supplies the reports to the Clients,
and whenever they open the Report, the Version Number of the Report should be matched in
the Oracle Server. Each Report will have its own Version Number, and it will change
whenever the Report is upgraded. In that situation new Reports have to be supplied to the
Clients. For that they are using the NMS Server, which is a central store of data, and they keep
the recent Reports in some directory. The Clients have to download the reports in some
specified directory, whenever their Reports will never be opened.
The Problem is that the Personnel in Sub Exchanges are not much trained to download or
upload the files from FTP Server.
The proposed system to solve the problem is that, a Server program, which always in
Listening state keeps track of all clients that are connected to the Server.Any client, can send a
file or message directly to other client(s) to the specified directory, and finally it receive the
acknowledgement. Server acts as a mediator and simply redirects the files from sender to
receiver. The clients are identified by their IP Addresses. This is a User Friendly Package, and
will have 2 modes of clients, Active and Passive. The ‘Sending’ option is been restricted to the
Passive clients, and they can only receive the files. Active Clients (DoTSoft) can
Send/Receive files. The Clients (probably of Passive mode) can be disconnected explicitly
after once the acknowledgement of ‘File Transferred’ is received. Not only .fmx files, any
kind of files can be sent using this System.
This Package has been developed in Java of version 1.3, which is based on Object Oriented
Methodology. There are several packages resided in Java and to develop this system, mainly
networking, swing packages of Java are used. Various features of Java made it a first choice of
the programmers. Java is a platform independent language, which can be run under any kind
of environment.

The main features involve,


1. Simple: - Java is a language which is based on Object Oriented Methodology, so it is
very easy to learn and can be used effectively.

2. Robust: - Java Programs are said to be robust because they will take care of memory
management and will never crash under any circumstances.

3. Secure: - Even though Java is developed using Object Oriented Principles, it eliminated
the Pointers Concept. So it is not possible to access memory directly, that’s why Java is
said to be Secure and is applicable for Internet, for that Applet is designed which can be
understandable by the browsers.

Packages Used: -

1. The default package to build any program in Java is lang that is used in developing this
system
2. The API to build Graphical User Interface in Java is provided using the packages awt
and swing. This system uses both the packages to provide GUI based forms.
3. To provide the communication over the network, the package net is used to develop the
Server and Clients.
4. In Java JDBC (Java Database Connectivity) is used to connect to the database, a special
package known as sql is developed for that.
5. The util package in Java is an enhancement of the existing classes. This package is also
used in this system for declaring arrays (Vector), and to manipulate the strings.
6. The streams that are used to send and receive the data over network are also utilized in
this system, which are in the package of io.

REQUIREMENTS ANALYSIS
Requirement Analysis is done to understand the problem the software system is to
solve. The emphasis in requirements analysis is on identifying what is needed from the
system, but not how the system will achieve the goals. This involves 2 phases,

1. Problem Analysis

2. Requirement Specification

Problem Analysis: -The basic aim of Problem Analysis is to obtain a clear understanding of
the needs of the clients, i.e. what exactly is desired from the software, what are the
constraints to be imposed while developing. After this phase the analyst will get a clear
idea about the project.
Since the system is developed using Objected Oriented Paradigm, the needs of the clients
are shown as Scenarios and Use cases. Some are listed below,

CLASS DIAGRAMS

The things naturally fall into categories we refer to those categories as classes. A class is a
category or group of things that have similar attributes and common behavior.
1. Class Diagram for a Client.

: Client

+ Socket
Instance
+ Input Stream
+ Output Stream
+ Host Address
+ Connected
Hosts

+ addLabel( )

2. Class Diagram for Server.

: Server

+ Socket
Instance
+ Input Stream
+ Output Stream
+ Number of
Client
+ Connected
Hosts

+addclient( )

USE CASE DIAGRAM

1. Use case & Scenario for the need to connect to the Server.
To Transfer To Send
File Message.
<<Include>>

Connect To
Server

Initiator Initiator
(User) (User)

Precondition: - Here the Initiator is some personnel in the department, who wants to send a
file or a message to some other client.

Actor Initializing: - A department personnel (One client)

Steps: - 1. The User connects to the Server to send a file or a message.


2. The User selects another client to whom he wanted to send
a file or message.
3. Exit.

Post condition: - The user gets connected to the Server.


2. Use case & Scenario to transferring file to single/multiple client(s).

Single Multiple

<<Include>>

File Transfer

Initiator Initiator
(User) (User)

Precondition: - Here the Initiator is the user, who wants to send a file to a single client or
multiple clients.

Actor Initializing: - A department personnel (One client)

Steps: - 1. The user first connects to the Server.


2. The user can select a single client or multiple clients to transfer
a file simultaneously.
3. Exit

Post condition: - The user gets the acknowledgement that the file has been reached.

3. Use case & Scenario for specifying the paths.


Source Destination
Path Path
<<Include>>

To Transfer
A File

Initiator Initiator
(User) (User)

Precondition: - Here the Initiator is a client, who wants to send a file.

Actor Initializing: - A department personnel (One client).

Steps: - 1. The User connects to the Server to send a file or a message.


2. The User selects another client to whom he wanted to send a file.
3. The User has to give the source path and the destination path correctly.
4. Exit.

Post condition: - The Specified file will be transferred to the specified location if exists, in the
remote system, if not ‘Path not found’ message has to be displayed.

4. Use case & Scenario to disconnect a single/multiple client(s).


Single Multiple

<<Include>>

Disconnect
Client
Initiator Initiator
(User) (User)

Precondition: - Here the Initiator is the user, who wants to disconnect a single or multiple
clients.

Actor Initializing: - A department personnel (One client).

Steps: - 1. The user first connects to the Server.


2. The user can select a single client or multiple clients to disconnect at a
time.
3. Exit.

Post condition: - The user’s presently connected clients list will be update.
E-R DIAGRAM

E-R Diagrams are used to represent the relation ship among the entities. In this
system there are only
2 entities that are Server and Client. So the Entity Relationship Diagram for this system is
drawn below,

1…1 1…*
Server client
INPUT
import java.awt.*;
import
java.awt.event.*;
import java.net.*;
import java.io.*;
import
javax.swing.*;
import java.util.*;
import java.sql.*;
class Ftpser {
public static void main(String ds[])
{
server3 s=new server3();
}
}
class server3 extends Thread
{
ServerSocket ser; Socket cli;
static int no=0; static Vector
v1=new Vector(10);
static int port=143;
Vector v=new Vector(10);
static Vector donot=new
Vector(10);
server3
() { try
{
ser=new ServerSocket(port);
start();
//setDaemon(true);
}catch(Exception e){System.out.println(e);}
}
public void run()
{ while(true)
{ try
{ cli=ser.acce
pt();
v.insertElementAt(new mul2(cli,this,no),no);
Runtime t=Runtime.getRuntime();
t.gc();
}catch(Exception e){System.out.println(e);}

}
}
void send(String
msg) //noted {
int flag=0; for(int
i=0;i<=no;i++)

{ flag=
0;
for(int j=0;j<donot.size();j++)
{
int
x=Integer.parseInt((String)donot.elementA
t(j)); if(i==x) flag=1; } if(flag==1)
continue; mul2 m=(mul2)v.elementAt(i);
m.out1(msg);
}
}
void send1(String msg)
{ int flag1=0;
for(int
i=0;i<no;i++)
{flag1=0;
for(int j=0;j<donot.size();j++)
{
int
x=Integer.parseInt((String)donot.elementA
t(j)); if(i==x) flag1=1; } if(flag1==1)
continue; mul2 m=(mul2)v.elementAt(i);
m.num=i;
m.out1(msg);
}
}
void send2(int no,String msg)
{
mul2 m=(mul2)v.elementAt(no);
m.out1(msg);
}
void sendall(int n,String msg)
{
for(int i=0;i<no;i++)
{ if(i==n) continue; mul2
m=(mul2)v.elementAt(i);
m.out1(msg);
}
}
void exit1(int n)
{
String s=v1.elementAt(n)+" exited123";
v.removeElementAt(n);
v1.removeElementAt(n);
donot.removeElement(new String().valueOf(n));
Runtime t=Runtime.getRuntime();
t.gc();
no--;
send1(s
); } }
class mul2 extends Thread
{
Socket client;
DataInputStream rin;
DataOutputStream
out; Statement
stmt; server3 ser;
String s;
String users; byte b[]=new
byte[200]; int num;
mul2(Socket cli,server3 ser,int
num)
{ try { client=cli; this.ser=ser;
this.num=num; rin=new
DataInputStream(cli.getInputStream());
out=new DataOutputStream(cli.getOutputStream());
start();
}catch(Exception e){System.out.println(e);}

} public void
run() {
String msg="";
StringTokenizer str;
try { while(true) { byte b[]=new
byte[200]; if(rin.read(b)>=1)
{ msg=new String(b).trim();
System.out.println("Hello");
System.out.println("Comming :
"+msg); if(msg.endsWith("
mustquit"))
{
str=new StringTokenizer(msg," ");
s=str.nextToken(); int
in=server3.v1.indexOf(s);
System.out.println("The number is
"+in); ser.send2(in," mustquit");
}
else
if(msg.indexOf("Theusername,")==
0)
{
str=new
StringTokenizer(msg," ");
str.nextToken(); String
user=str.nextToken();
users="";
server3.v1.insertElementAt(user,server3.no);
System.out.println(" user "+user+" Connected... with no
"+server3.no); for(int i=0;i<=server3.no;i++)
users=users+server3.v1.elementAt(i)+" ";
ser.send(users+"allusers"); server3.no++;
} else if(msg.indexOf("transfering ")==0 ||
msg.indexOf("transfferingtoall ")==0)
{

str=new StringTokenizer(msg," ");


str.nextToken(); int
size=Integer.parseInt(str.nextToken().tri
m());

String sender=str.nextToken().trim();
String all=str.nextToken("*");
String path=str.nextToken();
System.out.println("The
size :"+size); byte b1[]=new
byte[size];
rin.readFully(b1,0,size);

System.out.println("came out");
StringTokenizer str1=new StringTokenizer(all," ");
System.out.println(path);
String mess=sender+" "+"sizel "+size+"
"+path; int i=1;
while(i<str1.countTokens())
{
int
rec=server3.v1.indexOf(str1.nextToken().trim());
new sending(rec,b1,mess,ser);
}
}
else
if(msg.indexOf("nopath")>=0
)
{
System.out.println("Entered in nopath");
str=new StringTokenizer(msg," ");
str.nextToken();
String rece=str.nextToken(); int
x=server3.v1.indexOf(str.nextToken
()); ser.send2(x,"nopath in "+rece);
}

Source Code for Activeclient

import java.awt.*; import javax.swing.*; import java.awt.event.*; import


java.net.*; import java.io.*; import java.util.*; import java.sql.*; public class
chatform extends JFrame implements
Runnable,ActionListener,MouseListener {
JButton send,exit,kill;
JTextArea ta,ta1;
JTextField tf;
JLabel l1;
JScrollPane jsp,jsp1;
DataInputStream rin;
DataOutputStream out;
int n=0;
String user,mess;
JLabel l[]=new JLabel[100];
JPanel p2;
Vector v=new Vector();
Vector tip=new Vector();
//chat c1; static int
z=0; byte b[]=new
byte[50];
form f;
sendall all;
Connection con;
Statement stmt;
ResultSet
rs,rs1,rs2; static
int in=0;
public chatform(String user)
{
super("CONNECTED USERS
INFORMATION"); this.user=user; try{
Socket cli=new Socket("localhost",143);
rin=new
DataInputStream(cli.getInputStream());
out=new
DataOutputStream(cli.getOutputStream());
//InetAddress inet=InetAddress.getLocalHost();
//user=inet.getHostAddress();
byte x[]=("Theusername, "+user).getBytes();

System.out.println(new String(x));
out.write(x,0,x.length);
setSize(600,425);
setLocation(75,75);
show();
Container c=getContentPane();
JPanel p=new JPanel(new
BorderLayout()); JPanel p1=new
JPanel(new FlowLayout()); p2=new
JPanel(new GridLayout(100,1,0,10));
ta=new JTextArea(); tf=new
JTextField(50); ta.setFont(new
Font("",Font.BOLD,18));
ta.disable();
int v1=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
jsp=new JScrollPane(ta,v1,h);
p.add(jsp,BorderLayout.CENTER);
p.add(tf,BorderLayout.SOUTH
); send=new JButton("SEND
ALL"); exit=new
JButton("EXIT"); kill=new
JButton("KILL");
p1.add(kill); p1.add(send); p1.add(exit);
exit.addActionListener(this);
send.addActionListener(this);
kill.addActionListener(this); l1=new JLabel("
ALL CONNECTED USERS"); l1.setFont(new
Font("helvatica",Font.BOLD,22));
l1.setForeground(Color.darkGray);
/*ta.addMouseListener(new MouseAdapter()
{
public void mouseEntered(MouseEvent me)
{ ta.disable();
}
public void mouseExited(MouseEvent me){
ta.enable()
;} });*/ try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:raj");
stmt=con.createStatement();
rs=stmt.executeQuery("select *from users");

rs2=rs;
rs1=rs;
}
catch(Exception e){System.out.println(e);}
rin.read(b);
String str=new String(b).trim();
System.out.println(str);
StringTokenizer s=new StringTokenizer(str," "); while(s.hasMoreTokens())
{
String t=s.nextToken();
rs1=stmt.executeQuery("select *from users");
int flag=0,i=0;
if(!t.equals("allusers"))
{
ta.append(t+" :Presently Connected
"+"\n"); v.addElement(t);
while(rs1.next())
{
i++;
if(t.trim().equals(rs1.getString(1)))
{tip.addElement(rs1.getString(2));flag=1;}
}
if(flag==0)
tip.addElement("Not Updated");
System.out.println("sumitra"+i+" flag"+flag);
}
System.out.println(v.size()+" "+tip.size());
}

for(int i=0;i<100;i++)
{ l[i]=new
JLabel("");
p2.add(l[i]); }
jsp1=new JScrollPane(p2,v1,h);

addlabel();

c.setLayout(new BorderLayout());
c.add(l1,BorderLayout.NORTH);
c.add(p1,BorderLayout.SOUTH);
c.add(jsp1,BorderLayout.EAST);

c.add(p,BorderLayout.CENTER);

show();
Thread t=new Thread(this);
t.start();
}catch(Exception e){System.out.println("anand1 "+e);}
}

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource()==exit)
{
System.exit(0); }
if(ae.getSource()==s
end) {
Vector ve=new
Vector(v); in++; all=new
sendall(this,user,ve);
}
if(ae.getSource()==kill)
{
Vector ve=new Vector(v);
new killall(this,ve);
} } public void run()
{ String msg; try
{ while(true) { byte
b[]=new byte[200];
if(rin.read(b)>=1)
{
msg=new String(b).trim();
// System.out.println("Comming message :"+msg);
if(msg.endsWith("allusers"))
{
StringTokenizer s=new StringTokenizer(msg," ");
int x=s.countTokens();
for(int i=1;i<x-1;i++)
s.nextToken();

String u=s.nextToken();
ta.append(u+" :Recently Connected"+"\
n"); v.addElement(u);
rs2=stmt.executeQuery("select *from
users");
int flag=0;
while(rs2.next())
{
if(u.trim().equals(rs2.getString(1)))
{tip.addElement(rs2.getString(2));flag=1;}
}
if(flag==0)
tip.addElement("Not Updated");
System.out.println(v.size()+" "+tip.size());
addlabel();
}
else
if(msg.endsWith("exited123"))
{
System.out.println(msg);
StringTokenizer s=new StringTokenizer(msg," ");
String t=s.nextToken();
ta.append(t+" : Disconnected"+"\
n"); int x1=v.indexOf(t);
v.removeElement(t);
tip.removeElementAt(x1);
System.out.println(v.size()+" "+tip.size());
addlabel();
}
if(msg.indexOf("sizel")>=1)

{ int
flag=0;
System.out.println(msg);
StringTokenizer str=new StringTokenizer(msg," ");
String sender=str.nextToken();
str.nextToken(); int
size=Integer.parseInt(str.nextToken());
byte b1[]=new byte[size];
try
{
String pat=str.nextToken();
System.out.println("The dest Path "+pat);
FileOutputStream fout=new
FileOutputStream(pat); out.flush();
rin.readFully(b1,0,size);

fout.write(b1);
System.out.println("File Captured");
out.write(("captured "+" "+user+"
"+sender).getBytes()); //
System.out.println(new String(b1));
}catch(Exception e){System.out.println(e);flag=1;}

if(flag==1)
{
out.flush(); out.write(("nopath "+"
"+user+" "+sender).getBytes());
}
}
if(msg.startsWith("captured"))
{
System.out.println("Entered in captured");
System.out.println(msg);
StringTokenizer str=new StringTokenizer(msg," ");
str.nextToken();
str.nextToken();

String s=str.nextToken();

//System.out.println(f.status2.getText());
int ind=v.indexOf(s);
l[ind].setForeground(Color.cyan);
if(in==0)
f.status2.append("File Transfered To System:
"+s+"\n"); else
all.f.status2.append("File Transfered To System: "+s+"\n"); }
if(msg.startsWith("nopath"))
{
System.out.println("Entered in nopath");
System.out.println(msg);
StringTokenizer str=new
StringTokenizer(msg," "); str.nextToken();
str.nextToken();
String s=str.nextToken();
//System.out.println(f.status2.getText());
if(in==0)
f.status2.append("Path Not Found In System:
"+s+"\n"); else
all.f.status2.append("Path Not Found In System: "+s+"\n");
}

if(msg.endsWith("mustquit"))
{
System.out.println("You have been Forcibly removed from server");
System.exit(0);
}
}
}
}catch(Exception e){System.out.println("anand2 "+e);}
}
void addlabel()
{
System.out.println("The size is"+v.size());
for(int i=0;i<v.size();i++)
{
String t=" "+(String)v.elementAt(i)+" ";
System.out.println(t);
l[i].setFont(new Font("",Font.BOLD,16));
l[i].setText(t);
l[i].setToolTipText((String)tip.elementAt(i));
if(user.equals((String)v.elementAt(i)))
{l[i].setForeground(Color.red);

continue;} if(!
l[i].getForeground().equals(Color.cyan))
l[i].setForeground(Color.blue);
l[i].addMouseListener(this);
}
for(int j=v.size();j<10;j++)
{l[j].setText("");l[j].removeMouseListener(this);l[j].setToolTipText("");}
}
public void mousePressed(MouseEvent me){} public void
mouseEntered(MouseEvent me){setCursor(Cursor.HAND_CURSOR);}
public void mouseExited(MouseEvent me)
{setCursor(Cursor.DEFAULT_CURSOR);} public void
mouseClicked(MouseEvent me){ if(me.getClickCount()==1)
{
JLabel
l=(JLabel)me.getComponent();
in=0; f=new
form(this,l.getText(),user,null);
}

}
public void mouseReleased(MouseEvent me)
{} public static void main(String ds[])
{
new chatform(ds[0]);

}
}

OUTPUT
CONCLUSION
I would like to conclude that the System has been launched successfully in the real
environment, and is tested practically. The Files and Messages are transferred to the
intended clients basing on the selection. Even .EXE files are also been transferred
accurately with out any errors and perfectly executed after downloading.

REFRENCE
 https://nevonprojects.com/transferdatafile
 https://www.irjmets.com/uploadedfiles/paper/volume2/
issue_3_march_2020/276/1628082965 .pdf
 https://github.com/topics/file transfer data l-
 https://opus.govst.edu/cgi/viewcontent.cgi?article=1199&context=capstones
 https://www.mifratech.com/public/blogpage/transferdatafile
 https://www.mifratech.com/public/blog-page/filedatatransfer

You might also like