Computers & Internet Logo

Related Topics:

Posted on Jul 03, 2009
Answered by a Fixya Expert

Trustworthy Expert Solutions

At Fixya.com, our trusted experts are meticulously vetted and possess extensive experience in their respective fields. Backed by a community of knowledgeable professionals, our platform ensures that the solutions provided are thoroughly researched and validated.

View Our Top Experts

I need a complete workingsource code written in

I need a complete working source code written in java.

1 Answer

Anonymous

Level 3:

An expert who has achieved level 3 by getting 1000 points

All-Star:

An expert that got 10 achievements.

MVP:

An expert that got 5 achievements.

Vice President:

An expert whose answer got voted for 100 times.

  • Master 453 Answers
  • Posted on Jul 03, 2009
Anonymous
Master
Level 3:

An expert who has achieved level 3 by getting 1000 points

All-Star:

An expert that got 10 achievements.

MVP:

An expert that got 5 achievements.

Vice President:

An expert whose answer got voted for 100 times.

Joined: May 29, 2009
Answers
453
Questions
0
Helped
139435
Points
1391

This is a simple source code for Simple calculator in Java using RMI
//mathServer//
import java.rmi.*;
import java.rmi.Naming.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
import java.util.*;
interface mathInterface extends Remote
{
public int add(int a,int b) throws RemoteException;
public int subt(int a,int b) throws RemoteException;
public int mult(int a,int b) throws RemoteException;
public int div(int a,int b) throws RemoteException;
}
public class mathServer extends UnicastRemoteObject implements
mathInterface
{
public mathServer() throws RemoteException
{
System.out.println("Initializing Server");
}
public int add(int a,int b)
{
return(a+b);
}
public int subt(int a,int b)
{
return(a-b);
}
public int mult(int a,int b)
{
return(a*b);
}
public int div(int a,int b)
{
return(a/b);
}
public static void main(String args[])
{
try
{
mathServer ms=new mathServer();
java.rmi.Naming.rebind("MathServ",ms);
System.out.println("Server Ready");
}
catch(RemoteException RE)
{
System.out.println("Remote Server Error:"+ RE.getMessage());
System.exit(0);
}
catch(MalformedURLException ME)
{
System.out.println("Invalid URL!!");
}
}
}

//mathClient//
import java.rmi.*;
import java.rmi.registry.*;
import java.awt.*;
import java.awt.event.*;
public class mathClient extends Frame implements ActionListener
{
Button B1=new Button("Sum");
Button B2=new Button("Subtract");
Button B3=new Button("Multiply");
Button B4=new Button("Divide");
Label l1=new Label("Number 1");
Label l2=new Label("Number 2");
Label l3=new Label("Result");
TextField t1=new TextField(20);
TextField t2=new TextField(20);
TextField t3=new TextField(20);
public mathClient()
{
super("Calculator");
setLayout(null);
l1.setBounds(20,50,55,25);
add(l1);
l2.setBounds(20,100,55,25);
add(l2);
l3.setBounds(20,150,55,25);
add(l3);
t1.setBounds(150,50,100,25);
add(t1);
t2.setBounds(150,100,100,25);
add(t2);
t3.setBounds(150,150,100,25);
add(t3);
B1.setBounds(20,200,80,25);
add(B1);
B2.setBounds(100,200,80,25);
add(B2);
B3.setBounds(180,200,80,25);
add(B3);
B4.setBounds(260,200,80,25);
add(B4);
B1.addActionListener(this);
B2.addActionListener(this);
B3.addActionListener(this);
B4.addActionListener(this);
addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent AE)
{
if(AE.getSource()==B1)
{
sum();
}
else if(AE.getSource()==B2)
{
subt();
}
else if(AE.getSource()==B3)
{
mult();
}
else if(AE.getSource()==B4)
{
div();
}
}
public void sum()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.add(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void subt()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.subt(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void mult()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.mult(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void div()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.div(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public static void main(String args[])
{
mathClient MC=new mathClient();
MC.setVisible(true);
MC.setSize(600,500);
};
}

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

3helpful
1answer

I need source code in java for face recognition or iris recognition... please help me asap

Have you tried any of these? Most are in java...
Lots of others but they're written in C, C++, etc.

Hope that helps! :)
1helpful
1answer

How to program calculator in java

Hello,
If the question is : how to make a programmable calculator run a program written in Java, the amswer is : you cannot. Maybe the newer ones.

But if you are looking for the source code of a Java applet that simulates a calculator, then maybe you should launch a Google search with keywords Java calculator and see what you get. I do not want to spoil your fun by supplying a link to what my search returned.
Hope it helps.
1helpful
4answers

Java is not working

Hello there :
first you are going to want to ensure that your your current version of java is installed correctly and is not corrupted and if it needs to be reinstalled
download the latest java version and reinstall this . www.java.com
this should be able to take care of the problem that you are having ok?
best regards michael
1helpful
1answer

I need java source code for chat application reply

Your answer is here:
Solution # 1
http://www.web-tech-india.com/software/jsp_chat.php

Solution # 2
http://www.topshareware.com/java-source-codes-for-chat-application/downloads/1.htm

Solution # 3
http://www.codeproject.com/KB/java/java_applet_chat_with_gui.aspx

Good luck
0helpful
1answer

Java code needed

check these websites:
www.java2s.com/
www.sun.com/software/opensource/java/
www.planet-source-code.com/
www.freejavaguide.com/javasource.htm
www.javadb.com/

Good luck
0helpful
1answer

MS JVM and Sun JVM problem

Have you tried the oracle java site.

https://java.com/en/download/

you can download the latest or archived Java Runtime Environment or Java Development Kit from this site.

oracle obtained Java as part of the Sun buyout
1helpful
2answers

Java source code for detecting phone call

hello Asda

First things first:
1) Check the online manual for JAVA aplication, it tell all those codes you need.
Carl
http://java.sun.com/docs/books/tutorial/
Not finding what you are looking for?

580 views

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

k24674

Level 3 Expert

8093 Answers

Brad Brown

Level 3 Expert

19187 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...