Monday, May 17, 2010

SOME IMPORTANT INFO:

Java Syntax was derived from c-Language.
Java Obj' oriented features from c++.


>The code generated by FORTRAN,COBOL,BASIC are called "spaghetti code"-impossible to understand.
>The BCPL was designed by MARTIN RICHARDS.
>BCPL derivatin B was developed by -Ken Thompson.
>Later C was developed by Dennis Ritchie and Brain Kernighan.
>In the begining C was supplied with UNIX -os


Java-Some Basic Info:


-Java was firs named as "OAK" in 1991.
-Java compiler gives Byte Code
-Jvm interpreter converts the bytecode into executable code based on the platform.
-JIT-part of jvm converts the bytecode into executable form.

Expansions: [High Level Languages]

BCPL - Basic Combined Programmin Language.
BASIC - Beginners All Purpose Symbolic Instruction Code.
FORTRAN - FORmula Translation.
COBOL - Common Buisness Oriented Language.
PASCAL - Name of the Scientist.
ALGOL - ALGOrithmic Language.
PROLOG - PROgramming LOGic.
PL/1 - Programming Language 1.
LISP - LISt Processing.


Java was developed by:

James Gosling.
Patric Noughton.
Ed Frank.
Chris Wrath.
Mike Sheridan.
Bill Joy.
Jonathan Payne...


Sources :

Java complete Reference by Herbert Schildt.

Thursday, June 25, 2009

SIMPLE RMI DEFINITIONS WITH EXAMPLE

RMI-Remote Method Invocation.

Remote Method Invocation allows a java object that executes on one machine to invoke a method of java object that executes on another machine.This is an important feature,because it allows you to build distributed applications.

Example:

CLIENT SERVER APPLICATION BUILDING -USING RMI.

The server receives a request from a client ,process it and returns a result .
In this example the request specifies two numbers the server add these together and returns the SUM.

RMI-uses four java files

>interface.
>interface implementation.
>server.
>client.

Programmer must specify the above four steps while developing the RMI application.

1.)AddServerIntf.java
2.)AddServerImpl.java
3.)AddServer.java
4.)AddClient.java


AddServerIntf.java

Defines the Remoter Inerface that is provided by the server,here (in this program)it contains one mehtod that accepts two double arguments and return their sum.

* All Remote interfaces must extends fro "Remote"interface
* "Remote" interface -part of java.rmi.Remote //package
* it defines no members(Remote).


import java.rmi.Remote;
import java.rmi.*;
public interface AddServerIntf extends Remote
{
double add(double d1,double d2) throws RemoteException;
}



AddServerImpl.java

It implements the remote interface.The implementation of the add() method is straight forward.All remote object must extend 'UnicastRemoteObject',which provides functionality that is needed to make objects available from remote machines.


import java.rmi.*;
import java.rmi.server.*;
public calss AddServerImpl extends UnicastRemoteObject implements AddSeverIntf
{
public AddServerImpl()throws RemoteException
{}

public double add(double d1,double d2)throws Remote Exception
{
return d1+d2;
}

}



AddServer.java

The source file contains the main program for the server machine.It's primary function is to update the RMI registry on that machine . This is done by 'rebind' of 'Naming' class (java.rmi).

This method associates a name with an object reference the first argument to the rebind() method is string that names the server as "AddSever" , It's second argument is a reference to an instance of "AddSeverImpl"


import java.net.*;
import jva.rmi.*;
public class AddSever
{
try
{
AddServerImpl addserverimpl =new AddServerImpl();
Naming.rebind("AddServer",addserverimpl);
}
catch(Exception e)
{
System.out.println("Exception"+e.toString());
}
}



AddClient.java

* Implements the client side of this application.
* Requires three cmd line arguments .
* first -ip address or name of server machine.
* second and third arguments are 2-nos that are to be summed
* it begins by forming a string that follows the URL syntax.
* This URL uses the RMI protocol (java.rmi).
* The string includes the ip address or name of the server and the string "AddServer"
* This program then invokes the "lookup()" method of the naming class.
* "lookup()" accepts one argument , the rmi URL, and returns to an object of type AddServerIntf.

* All remote method invocations can then be directed to this object.

The program continues by displaying its arguments and then invokes the remote 'add()' method .The sum is returned from this method and is then printed.

import java.rmi.*;
public class AddClient
{
public static void main(String args[])
{
try {
String addserverurl="rmi://"+args[0]+"AddServer";
AddServerIntf addserverintf=(AddServerIntf)Naming.lookup(addserverurl);
System.out.println("The First Number :"+args[1]);
double d1=Double.valueOf(args[1].doubleValue();
System.out.println("The Second Number :"+args[2]);
double d2=Double.valueOf(args[2]).doubleValue();
System.out.println("\nThe Sum is :"+addserverintf.add(d1,d2));
}
catch(Exception e)
{
System.out.println("Exception :"+e);
}

}
}


COMPILING PROCEDURES :

1. SAVE ALL THE FILES WITH ITS CORRESSPONDING NAME WITH IN A SAME DIRECTORY.

2. COMPILE ALL THE JAVA FILES
EX:
C:/RMI>JAVAC *.JAVA

3. CLEAR ALL THE ERRORS IF U FIND ANYTHING.

4. AFTER SUCCESSFULL COMPILATION YOU WILL GET THE CLASS FILES FOR ALL THE JAVA FILES

5. CREATING STUB AND SKELETON
EX:
C:/RMI>RMIC AddServerIntf.class

//you can get the stub and skeleton files after executing the above cmd.

6. STARTING RMI REGISTRY.
EX:
C:/RMI>START RMIREGISTRY

7. STARTING THE RMI SERVER
EX:
C:/RMI>JAVA AddServer

8. STARTNG THE RMI CLIENT
EX:
C:/RMI>JAVA AddClient sysname 10 20

OUTPUT:

C:/RMI>JAVA AddClient sysname 10 20
The First Number : 10
The second Number : 20
The Sum is : 30


MORE DETAILS
HOW TO CREAE RMI SYSTEM.


BOOK REFERENCE
JAVA COMPLETE REFERENCE 5TH EDITION BY HERBERT SCHILDT

SOME IMPORTANT INFO

1.)THE LANGUAGE USED TO WRITE THE UNIX OS-----B - BCPL.


2.)FILE SYSTEM USED IN MAC-OS -HFS.(HEIRARICHAL FILE SYSTEM.)
>NTFS.
>HFS.
>ZFS
>OCFS

3.)FILE SYSTEM USED IN FLASH DEVICES. ?--------ExFAT


4.)FILE SYSTEM USED IN SOLARIS -ZFS.(DECENTRALIZED FILE SYSTEM.)

>NTFS.
>HFS.
>ZFS
>XFS.

5.)MINIX OS WAS DEVELOPED BY ------A.S.TANENBAUM

6.)A PROGRAM DESIGNED TO PROTECT AGAINST SPYWARE AND OTHER UNWANTED S/W BY WXP -WINDOWS DEFENDER.

7.)WHAT IS THE NAME OF THE VIRUS THAT ALLOW OTHERS TO ENTER INTO OUR SYSTEM AND USE IT FOR THEIR OWN PURPOSE.---- BACK DOOR TROJANS.

8.) WE CAN GET THE VIRUS FROM THE WEBSITE. -TRUE / FALSE...(FALSE)

9.) EXPANSION OF VFS .?-------------------------------VIRTUAL FILE SYSTEM.


10.)EXPANSION FOR OCX-OBJECT LINKING AND EMBEDDING CONTROL EXTENSION

11.) A UTILITY THAT HELPS U TO CHECK THE SPELLING OF WORDS IN WORD PROCESSORS.-SPELL CHECKER.


12.)WHICH IS THE SUPER CLASS FOR ALL THE CLASSES IN JAVA------ OBJECT.


13.)EXPANSION OF POST. ?----------------------------- POWER ON SELF TEST.


14.)WHICH IS THE SOFTWARE THAT ENABLES THE ADVERTISERS TO GATHER THE INFORMATION ABOUT A COMPUTER USER'S.------


15.)EXPANSION OF AMD .?------------------------------ADVANCED MICRO DEVICES.

16.)THE FIRST COMPUTERS DID NOT HAVE THE OS.-T/F----'T'

17.)EXPANSION OF JFS .?--------------------------------JOURNALIZED FILE SYSTEM(FILE SYSTEM SUPPORTED BY LINUX).



18.)Is it possible to have multiple classes having main method in a java application? ---- YES/NO-------YES.


19.)EXPANSION OF CLI ? -COMMAND LINE INTERFACE.

>COMMAN LANGUAGE INTERFACE.
>COMMAND LINE INTERFACE.
>COMMAN LINKAGE INTERFACE.


20.) WHICH OF THE FOLLOWING FUNCTION IS USED TO RELEASE THE ALLOCATED MEMORY IN C LANGUAGE--FREE()

>UNALLOC()
>RELEASE()
>DEALLOC()
>FREE()
>DROPMEM