Sunday, 19 August 2012

ADVANCED SOFTWARE ENVIRONMENTS FULL NOTES MG UNIVERSITY






NAME : ADVANCED SOFTWARE ENVIRONMENTS FULL NOTES MG UNIVERSITY
UTY :mgu .
Branch: Computer Science And Engineering. 

 

Infosys Placement Paper (sample Question With Answer)


                Name:    Infosys Placement Paper (sample Question With Answer)

                                         Download Now

NP Lab Viva Questions

:
Name : NP Lab viva Question
Document Type: doc

Download Now

Wednesday, 1 August 2012

Java Program for implement Inter Applet communication In The Distributed System

Aim
Write a java program to implement Inter applet communication in the Distributed System
Program

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

/*<applet code="FirstApplet.class"  width=300 height=300 name="first">
</applet>*/
/*<applet code="SecondApplet.class" width=300 height=300 name="second"></applet>*/

public class FirstApplet extends JApplet implements ActionListener
{
JTextArea ta;
JButton b1;
JTextField txt1;

public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout(FlowLayout.LEFT));
txt1=new JTextField(20);
b1=new JButton("send");
ta=new JTextArea(20,30);
ta.setEditable(false);
b1.addActionListener(this);
c.add(txt1);
c.add(b1);
c.add(ta);
}
public void actionPerformed(ActionEvent ae)
{
JApplet second=(JApplet)getAppletContext().getApplet("second");
((SecondApplet)second).ta.append("first>"+txt1.getText()+"\n");
ta.append("first>"+txt1.getText()+"\n");
txt1.setText("");
}
}

Bidirectional Datatransfer Using Threads

Aim
Write a program to perform bi directional data transfer using Threads .
Progrram

  thserver.java
import java.io.*;
import java.net.*;
public class thserver implements Runnable
{
Thread t1=null,t2=null;
BufferedReader in,br;
PrintWriter pw;
Socket s;
ServerSocket ser;

public thserver()
{
    try
    {
    int port=8002;
    ser=new ServerSocket(port);
    }

    catch(Exception e)
     {System.out.println("ERROR");}
}

public void run()
{
String msg;
if(Thread.currentThread()==t1)
{
    try
    {
    s=ser.accept();
    br=new BufferedReader(new InputStreamReader(s.getInputStream()));
   
    do
    {
    System.out.println("Enter a message");
    msg=br.readLine();
    System.out.println("Client:"+msg);
    }while(!msg.equals("Quit"));
    System.exit(0);
    }
catch(Exception e)
{
System.out.println("Error running program");
}
}

else
{
    try
    {
    in=new BufferedReader(new InputStreamReader(System.in));
    do
    {
    msg=in.readLine();
    pw=new PrintWriter(s.getOutputStream(),true);
    pw.println(msg);
    }while(!msg.equals("Quit"));
    System.exit(0);
    }
    catch(Exception e)
    {
    System.out.println("Error running program");
    }
}
}

public static void main(String args[])

{
thserver ss=new thserver();
System.out.println("Sever started");
ss.t1=new Thread(ss);
ss.t2=new Thread(ss);
ss.t1.start();
ss.t2.start();
}
}