Java RMI Simple Bank System run on ubuntu

This is a simple Java RMI application where the server manages the bank accounts which are stored in a database and responds to the client requests. The system permits multiple clients to be able to access the server from remote PCs. The client, after he has log in, is able to check his account details, withdraw and and deposit money into his account. It may also help to compile/run Java RMI system on ubuntu

github link:


To run Java RMI server/client on ubuntu, run the following commands on terminal:

cd ‘/directory’

//compile .java files






rmic BankAccount

rmiregistry 2008

//run the server with mysql dependency

java -cp “/mysqldirectory/mysql-connector-java-5.1.23:.”BankServer

//run the client

java BankClient

A simple TCP Socket calculator

A simple TCP Socket calculator


//Server Class

public class SimpleServer {
public static void main(String args[]) throws IOException {
// Register service on port 1254
ServerSocket s = new ServerSocket(1251);
Socket s1=s.accept(); // Wait and accept a connection
// Get a communication stream associated with the socket

InputStream s1In = s1.getInputStream();
DataInputStream dis = new DataInputStream(s1In);
int num1 = (dis.readInt());
int num2 = (dis.readInt());
String operation = (dis.readUTF());
int ans = 0;
if (operation.equals(“add”) == true){
ans = num1 + num2;
else if (operation.equals(“sub”)){
ans = num1 – num2;
// Close the connection, but not the server socket


//Client Class

public class SimpleClient {
public static void main(String args[]) throws IOException {
// Open your connection to a server, at port 1254
Socket s1 = new Socket(“localhost”,1251);
// Get an input file handle from the socket and read the input
Scanner scanln = new Scanner(;

//System.out.println(“Enter number1: “);
//int num1 = scanln.nextInt();

//System.out.println(“Enter number2: “);
//int num2 = scanln.nextInt();

System.out.println(“Search Movie: “);
String searchmovie =;

OutputStream s1out = s1.getOutputStream();
DataOutputStream dos = new DataOutputStream (s1out);
//dos.writeInt(num1); //send to server6
//dos.writeInt(num2); //send to server6
//dos.writeInt(operation); //send to server6

//GUI.HomeMenu.homeMenu=new GUI.HomeMenu();
InputStream s1In = s1.getInputStream();
DataInputStream dis = new DataInputStream(s1In);
String st = new String (dis.readUTF());

System.out.println(“” + st);
// When done, just close the connection and exit

Paint & using Mouse in Java

/** this simple program allows user to draw by click & drag with the mouse. The example contains “” and “” classes. The “select paint” method in “” can be used to add new paint style, e.g, different colors. Any queries, feel free to ask…

By Devansh Ramen



import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
public class Main {

public static void main(String[] args) {
JFrame window = new JFrame(“Clipping”);
draw content = new draw();



import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.JPanel;
//MouseListener: interface containing methods required to ‘listen’ to mouse events
public class draw extends JPanel implements MouseListener, MouseMotionListener {

private int prevX, prevY;
private Graphics paint;
private Polygon triangle= new Polygon();
private String drawtype;

public draw() {

private void selectpaint() {
paint = getGraphics();
drawtype = “line”;
// to choose polygon to draw

public void mousePressed(MouseEvent evt) {
int x = evt.getX(); // capture start position
int y = evt.getY();
prevX = x; //set previous same position at first
prevY = y;

public void mouseReleased(MouseEvent evt) {
paint = null;

public void line(MouseEvent evt){
int x = evt.getX(); // capture new x coordinate
int y = evt.getY(); // capture new y coordinate
paint.drawLine(prevX, prevY, x, y);
prevX = x;
prevY = y;

public void mouseDragged(MouseEvent evt) {
if (drawtype== “line”){


public void mouseMoved(MouseEvent evt) { } //mouse moves but no button pressed
public void mouseEntered(MouseEvent evt) { }
public void mouseExited(MouseEvent evt) { }
public void mouseClicked(MouseEvent evt) { }