Advanced programs

java program for Client-Server Program using TCP/IP

java program for Client-Server Program using TCP/IP

Program : Client-Server Program using TCP/IP By : Kapil Lohia import java.net.*; import java.io.*;   class tcpip_server { public static void main(String args[]) throws IOException { ServerSocket n1=null; try { n1=new ServerSocket(98); } catch(IOException e) { System.err.println("Port 98 could not be found"); System.exit(1); } Socket c=null; try { c=n1.accept(); System.out.println("Connection from "+c); } catch(IOException e) […]

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

Java program to display the IP Address of a particular Host

Java program to display the IP Address of a particular Host

Program : To display the IP Address of a particular Host By : Kapil Lohia import java.net.*; import java.io.*;   public class ip_host { public static void main(String args[]) throws Exception { System.out.println("Enter the host name :"); String n=new DataInputStream(System.in).readLine();   InetAddress ipadd =InetAddress.getByName(n);   System.out.println("IP address :"+ipadd); } }

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

Java program to display Local machines IP Address

Java program to display Local machines IP Address

Program : To display Local machines IP Address By : Kapil Lohia import java.net.*; import java.io.*;   public class ip_localmachine { public static void main(String args[]) throws Exception { InetAddress ipadd =InetAddress.getLocalHost(); System.out.println("Host and Address :"+ipadd); System.out.println("Host name :"+ipadd.getHostName());   String n=ipadd.toString(); System.out.println("IP address :"+n.substring(n.indexOf("/")+1)); } }

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

java program for Client-Server Program using TCP/IP

java program for Client-Server Program using TCP/IP

Program : Client-Server Program using TCP/IP By : Kapil Lohia Program 1:   import java.net.*; import java.io.*;   class tcpip_server { public static void main(String args[]) throws IOException { ServerSocket n1=null; try { n1=new ServerSocket(98); } catch(IOException e) { System.err.println("Port 98 could not be found"); System.exit(1); } Socket c=null; try { c=n1.accept(); System.out.println("Connection from "+c); […]

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

DatagramSocket and DatagramPacket (Client-Server Program using UDP/IP)

DatagramSocket and DatagramPacket (Client-Server Program using UDP/IP)

Program : DatagramSocket and DatagramPacket (Client-Server Program using UDP/IP) By : Kapil Lohia Program 1 :   import java.net.*;   class udpip_server { public static DatagramSocket ds; public static byte buffer[]=new byte[1024];   public static void Myserver() throws Exception { int pos=0; while(true) { int c=System.in.read(); switch(c) { case -1: System.out.println("Server quits"); return; case ‘\r’:break; […]

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

Java program for Uniform Resource Locator (URL)

Java program for Uniform Resource Locator (URL)

Program : Uniform Resource Locator (URL) By : Kapil Lohia import java.net.*; import java.io.*;   class url { public static void main(String args[]) throws Exception { URL n1 = new URL("http://java.sun.com:80/docs/index#down"); System.out.println("Protocol:"+n1.getProtocol()); System.out.println("Host :"+n1.getHost()); System.out.println("File Name :"+n1.getFile()); System.out.println("Port :"+n1.getPort()); System.out.println("Reference :"+n1.getRef()); } }

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

Java program to display a clock

Java program to display a clock

background_ = new GSegment();
GStyle backgroundStyle = new GStyle();
backgroundStyle.setBackgroundColor (new Color (122, 136, 161));
backgroundStyle.setForegroundColor (new Color (0, 0, 0));
background_.setStyle (backgroundStyle);
addSegment (background_);

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone

Java Program for calculator

Java Program for calculator

JPanel p = new JPanel();
p.setLayout(new GridLayout(4, 4));
String buttons = “789/456*123-0.=+”;
for (int i = 0; i < buttons.length(); i++)
addButton(p, buttons.substring(i, i + 1));
add(p, “Center”);

Share on FacebookTweet about this on TwitterDigg thisPin on PinterestShare on LinkedInShare on StumbleUponShare on TumblrShare on Google+Email this to someone