Friday, 3 October 2014

Cloud Computing !!





Have you ever thought how we take advantage of Google Drive and Gmail or how we are using Facebook.How is our data stored on Google ?






The force behind this is CLOUD COMPUTING
Cloud Computing is all about different computers interlinked to data-processing tasks, centralized data storage, sharing of resources and data and also online access to computer services or resources.
In cloud computing one does not need to buy the required resources, you only need to use a shared cloud infrastructure and pay for it.
Internet is also a type of cloud computing.

n a cloud computing system, there's a significant workload shift. Local computers no longer have to do all the heavy lifting when it comes to running applications. The network of computers that make up the cloud handles them instead. Hardware and software demands on the user's side decrease. The only thing the user's computer needs to be able to run is the cloud computing system's interface software, which can be as simple as a Web browser, and the cloud's network takes care of the rest.

Service Models in Cloud Computing :


1. SaaS: In the business model using software as a service (SaaS), users are provided access to application software and databases. Cloud providers manage the infrastructure and platforms that run the applications. SaaS is sometimes referred to as "on-demand software" and is usually priced on a pay-per-use basis.Software-as-a-Service provides complete applications to a cloud’s end user.
2. Platform as a service (PaaS) : In the PaaS models, cloud providers deliver a computing platform, typically including operating system, programming language execution environment, database, and web server. Application developers can develop and run their software solutions on a cloud platform without the cost and complexity of buying and managing the underlying hardware and software layers. With some PaaS offers like Microsoft Azure and Google App Engine, the underlying computer and storage resources scale automatically to match application demand so that the cloud user does not have to allocate resources manually.
3. Infrastructure as a service (IaaS) : The services on the infrastructure layer are used to access essential IT resources that are combined under the heading Infrastructure-as-a-Service (IaaS). These essential IT resources include services linked to computing resources, data storage resources, and the communications channel. They enable existing applications to be provisioned on cloud resources and new services implemented on the higher layers.
4. Data as a service : comprises data delivered as a service rather than being stored locally. The data may be consumed by tradional on-premises software, smart clients, websites or SaaS solutions.Typically the data is prepared and formatted ready for use by the client software.


Deployment models :

Public Cloud
 The deployment of a public cloud computing system is characterized on the one hand by the public availability of the cloud service offering and on the other hand by the public network that is used to communicate with the cloud service. The cloud services and cloud resources are procured from very large resource pools that are shared by all end users.

Private Cloud
Private cloud computing systems emulate public cloud service offerings within an organization’s boundaries to make services accessible for one designated organization. Private cloud computing systems make use of virtualization solutions and focus on consolidating distributed IT services often within data centers belonging to the company.

Hybrid Cloud
A hybrid cloud service deployment model implements the required processes by combining the cloud services of different cloud computing systems, e.g. private and public cloud services. The hybrid model is also suitable for enterprises in which the transition to full outsourcing has already been completed, for instance, to combine community cloud services with public cloud services.

Sunday, 27 July 2014

if adt doesn't start??? ADT error !!! Solve it now :)

what to do if your adt bundle suddenly stops working? it happened with me... when i started the adt eclipse, it just appeared for a flash of time and the adt startup screen disappeared.. so i have a solution for this...
if this happens with you all you have to do is

  1. go to the folder where you have saved all the adt files
  2. then delete the metadata  folder
  3. reopen the eclipse
  4. it will work as it was working previously
  5. if you are facing some other problem you can comment below... we will solve your problem 

Monday, 21 July 2014

program to play music in JFrame

import java.io.*;
import java.net.URL;
import javax.sound.sampled.*;
import javax.swing.*;
 
// To play sound using Clip, the process need to be alive.
// Hence, we use a Swing application.
public class sounds extends JFrame {
 
   // Constructor
   public sounds() {
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      this.setTitle("Test Sound Clip");
      this.setSize(300, 200);
      this.setVisible(true);
   
      try {
   
         // Open an audio input stream.
         URL url = this.getClass().getClassLoader().getResource("mus.wav");
         //
          AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
         // Get a sound clip resource.
          for(int i=0; i<10; i++){   Clip clip = AudioSystem.getClip();
         // Open audio clip and load samples from the audio input stream.
         clip.open(audioIn);
         clip.start();}
      } catch (UnsupportedAudioFileException e) {
     JOptionPane.showMessageDialog(this, e.getMessage());
         e.printStackTrace();
      } catch (IOException e) { JOptionPane.showMessageDialog(this, e.getMessage());
         e.printStackTrace();
      } catch (LineUnavailableException e) { JOptionPane.showMessageDialog(this, e.getMessage());
         e.printStackTrace();
      }
   }
 
   public static void main(String[] args) {
      new sounds();
   }
}

Wednesday, 16 July 2014

Program to play and stop music on your choice in java applet

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class mus3 extends Applet
implements ActionListener{
   Button play,stop;
   AudioClip audioClip;
   public void init(){
      play = new Button("  Play ");
      add(play);
      play.addActionListener(this);
      stop = new Button("  Stop  ");
      add(stop);
      stop.addActionListener(this);
      audioClip = getAudioClip(getCodeBase(), "mus.wav");
   }
   public void actionPerformed(ActionEvent ae){
      Button source = (Button)ae.getSource();
      if (source.getLabel() == "  Play  "){
         audioClip.play();
      }
      else if(source.getLabel() == "  Stop  "){
         audioClip.stop();
      }
   }
}

Tuesday, 15 July 2014

Program to play music in java Applet

import java.applet.*;
import java.awt.*;

public class music1 extends Applet {
   Button play,stop;
   AudioClip audioClip;
   public void init(){
   
      audioClip = getAudioClip(getCodeBase(), "mus.wav");
      audioClip.play();
   }
 
}

Saturday, 28 June 2014

Program to show the example of radio buttons

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
public class Radio extends Applet implements ActionListener
{
Checkbox ch1,ch2;
CheckboxGroup cbg;
Button b1;

public void init()
{
cbg=new CheckboxGroup();
b1=new Button("check");
ch1= new Checkbox("male",cbg,true);
ch2= new Checkbox("female", cbg,true);
add(ch1);
add(ch2);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
String a=" ", b=" ", c=" ";
if(e.getSource()==b1)
{
if(ch1.getState()==true)
{a="male";}
else if(ch2.getState()==true)
{b="female";}

JOptionPane.showMessageDialog(this, "u have selected "+a+b);

}
}}

output:


Program to show two listed choices and print their table

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Mullist extends Applet implements ItemListener{
Choice ch1,ch2;
List l1;
int c,d;
public void init()
{
ch1=new Choice();
ch2=new Choice();
l1=new List(10);
for(int i=1; i<=100; i++)
{
ch1.add(String.valueOf(i));
ch2.add(String.valueOf(i));
}
add(ch1);
add(ch2);
add(l1);
ch1.addItemListener(this);
ch2.addItemListener(this);

}
public void itemStateChanged(ItemEvent e) {
if(e.getSource()==ch1)
{
c=Integer.parseInt(ch1.getSelectedItem());
}
if(e.getSource()==ch2)
{
d=Integer.parseInt(ch2.getSelectedItem());
}

for(int i=1; i<=d; i++)
{
l1.add(""+c+"x"+i+"="+c*i+"\n");
}
}

}

output:




Friday, 27 June 2014

Make your own KBC(kaun banega crorepati) game

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
public class Kbc extends Applet implements ActionListener{
Label l1,l2,l3;
Panel p1,p2,p3,p4;
CheckboxGroup c1,c2,c3;
Checkbox  ch1,ch2,ch3,ch4,ch5,ch6,ch7,ch8,ch9,ch10,ch11,ch12;
Button b1,b2,b3,b4;


public void init()
{
setLayout(null);
p1=new Panel();
p1.setBounds(100,10,800,500);
add(p1);
c1=new CheckboxGroup();
c2=new CheckboxGroup();
c3=new CheckboxGroup();
b1= new Button("lock the answer");
l1 = new Label();
l1.setText("Q1: what is the capital of india?");
p1.add(l1);
ch1= new Checkbox("delhi",c1,false);
ch2= new Checkbox("chandigarh", c1,false);
ch3= new Checkbox("manipur", c1,false);
ch4= new Checkbox("mumbai", c1,false);
p1.add(ch1);
p1.add(ch2);
p1.add(ch3);
p1.add(ch4);
p1.add(b1);
b1.addActionListener(this);
p2=new Panel();
p2.setBounds(100,10,800,500);
add(p2);
b2= new Button("lock the answer");
l2 = new Label();
l2.setText("Q2: who is the founder of facebook");
p2.add(l2);
ch5= new Checkbox("mark zukerberg",c2,false);
ch6= new Checkbox("james wat", c2,false);
ch7= new Checkbox("sherlock", c2,false);
ch8= new Checkbox("orkut", c2,false);
p2.add(ch5);
p2.add(ch6);
p2.add(ch7);
p2.add(ch8);
p2.add(b2);
b2.addActionListener(this);
p3=new Panel();
p3.setBounds(100,10,800,500);
add(p3);
b3= new Button("lock the answer");
l3 = new Label();
l3.setText("Q2: what is the capital of punjab?");
p3.add(l3);
ch9= new Checkbox("iraq",c3,false);
ch10= new Checkbox("chandigarh", c3,false);
ch11= new Checkbox("crap", c3,false);
ch12= new Checkbox("mumbai", c3,false);
p3.add(ch9);
p3.add(ch10);
p3.add(ch11);
p3.add(ch12);
p3.add(b3);
b3.addActionListener(this);

p1.setBackground(Color.blue);
p2.setBackground(Color.cyan);
p3.setBackground(Color.pink);


p4=new Panel();
p4.setBounds(100,10,800,500);
add(p4);
p4.setBackground(Color.gray);
b4=new Button("done");
p4.add(b4);
b4.addActionListener(this);
p1.setVisible(true);
p2.setVisible(false);
p3.setVisible(false);
p4.setVisible(false);
}
public void actionPerformed(ActionEvent e) {
String a=" ", b=" ";

if(e.getSource()==b1)
{
if(ch1.getState()==true)
a="right";
else if(ch2.getState()==true)
b="wrong";
else if(ch3.getState()==true)
b="wrong";
else if(ch4.getState()==true)
b="wrong";

JOptionPane.showMessageDialog(this, "u have selected "+a+b);
p1.setVisible(false);
p2.setVisible(true);
p3.setVisible(false);
p4.setVisible(false);
}
if(e.getSource()==b2)
{
if(ch5.getState()==true)
a="right";
else if(ch6.getState()==true)
b="wrong";
else if(ch7.getState()==true)
b="wrong";
else if(ch8.getState()==true)
b="wrong";
JOptionPane.showMessageDialog(this, "u have selected "+a+b);
p1.setVisible(false);
p2.setVisible(false);
p3.setVisible(true);
p4.setVisible(false);
}
if(e.getSource()==b3)
{
if(ch9.getState()==true)
b="wrong";
else if(ch10.getState()==true)
a="right";
else if(ch11.getState()==true)
b="wrong";
else if(ch12.getState()==true)
b="wrong";
JOptionPane.showMessageDialog(this,"u have selected "+a+b);
p1.setVisible(false);
p2.setVisible(false);
p3.setVisible(false);
p4.setVisible(true);
}
if(e.getSource()==b4)
System.exit(0);
}}

Wednesday, 25 June 2014

Program to print delayed output using multithreading


public class loading implements Runnable{


public void run() {
// TODO Auto-generated method stub
int i;

for(i=0; i<=5; i++)
{
try
{

Thread.sleep(1000);

}
catch(Exception e){}
System.out.println("i="+i);
}

}
public static void main(String[] args)
{
loading l=new loading();
Thread t=new Thread(l);
t.start();

}}

output:
i=0
i=1
i=2
i=3
i=4
i=5

Program to print delayed output

import javax.swing.*;

public class delayed {

public static void main(String[] args)
{
int i;

for(i=0; i<=5; i++)
{
try
{

Thread.sleep(1000);

}
catch(Exception e){}
System.out.println("i="+i);
}

}}

output:
i=0
i=1
i=2
i=3
i=4
i=5