6728719-java

Upload: mufasir

Post on 08-Apr-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 6728719-Java

    1/43

    Automatic Response SystemAutomatic Response System

    Using SmsUsing Sms

  • 8/7/2019 6728719-Java

    2/43

    Contents:Contents:

    MethodologyMethodology Why Java?Why Java?

    Reasons for using javaReasons for using java

    Comparison to other langaugesComparison to other langauges

    History of JavaHistory of Java

    IntroductionIntroduction Primary goals of using javaPrimary goals of using java

    Types of JavaTypes of Java

    CritisismCritisism

    JSMS:JSMS:Software Architecture

    JSMS Supported Protocols

    Message Types

    ReferencesReferences::

  • 8/7/2019 6728719-Java

    3/43

    MethodologyMethodology

    Mobile is connected to serial port of computer.Mobile is connected to serial port of computer.

    Whenever any message arrives on that mobile ,it isWhenever any message arrives on that mobile ,it is

    accepted by java program running on the computer.accepted by java program running on the computer.

    Program will read message arrived on pc & extractProgram will read message arrived on pc & extract

    the contents.the contents.

    Depending upon contents of message, program willDepending upon contents of message, program will

    connect to particular database for specific data askedconnect to particular database for specific data askedin the Sms.in the Sms.

  • 8/7/2019 6728719-Java

    4/43

    Contd.Contd.

    Data is retrieved & an sms is framed.Data is retrieved & an sms is framed.

    This sms is tranferred to the mobileThis sms is tranferred to the mobile

    connected to pc using JSMS API.connected to pc using JSMS API. It will send sms to requesting mobile usingIt will send sms to requesting mobile using

    program.program.

    We are using Java for developing theWe are using Java for developing theapplication.application.

  • 8/7/2019 6728719-Java

    5/43

    WhyWhy JAVAJAVA??

    JavaJava is ais a programming languageprogramming language originally developedoriginally developed

    byby Sun MicrosystemsSun Microsystems and released in 1995. Theand released in 1995. The

    language derives much of itslanguage derives much of its syntaxsyntax fromfrom CC andand C++C++

    but has a simplerbut has a simplerobject modelobject model and fewer lowand fewer low--levellevelfacilities. Java applications are typicallyfacilities. Java applications are typically compiledcompiled toto

    byte code which can run on any Javawhich can run on any Java virtual machinevirtual machine

    regardless ofregardless ofcomputer architecturecomputer architecture. Java now forms. Java now forms

    the core of Sun'sthe core of Sun's Java platformJava platform..

  • 8/7/2019 6728719-Java

    6/43

    Reasons for using JAVA:Reasons for using JAVA:

    Java Is Small and SimpleJava Is Small and Simple ::The most complex partsThe most complex parts

    of C++ were excluded from Java, such as pointersof C++ were excluded from Java, such as pointers

    and memory management. These elements areand memory management. These elements are

    complicated to use, and are thus easy to usecomplicated to use, and are thus easy to useincorrectly.incorrectly.

    Java Is Object Oriented :OOP organizes aJava Is Object Oriented :OOP organizes a

    program as a set of components called objects.program as a set of components called objects.

    These objects exist independently of each other,These objects exist independently of each other,

    and they have rules for communicating with otherand they have rules for communicating with other

    objects and for telling those objects to do things.objects and for telling those objects to do things.

  • 8/7/2019 6728719-Java

    7/43

    Contd.Contd.

    Java is Dynamic :Java is Dynamic :Java programmes carry with themJava programmes carry with themsubstantial amounts of runsubstantial amounts of run--time type information thattime type information that

    is used to verify and resolve accesses to objects at runis used to verify and resolve accesses to objects at run--

    time. This makes it possible to dynamically link codetime. This makes it possible to dynamically link code

    in a safe and expedient manner. This is crucial to thein a safe and expedient manner. This is crucial to therobustness of the applet environment.robustness of the applet environment.

    Java is ArchitectureJava is Architecture--Neutral :Neutral :The JavaThe Java

    designers made several hard decisions in thedesigners made several hard decisions in the

    Java language and the Java Virtual Machine inJava language and the Java Virtual Machine in

    an attempt to alter the situation of programmesan attempt to alter the situation of programmes

    not running on the same machine after fewnot running on the same machine after few

    days.days.

  • 8/7/2019 6728719-Java

    8/43

    Comparison to other languagesComparison to other languages

    Multiple VendorChoice and SupportMultiple VendorChoice and Support

    Java technologies are supported by multiple vendors allowingJava technologies are supported by multiple vendors allowing

    mix and match and best of breed solutions. Java standard APIsmix and match and best of breed solutions. Java standard APIs

    have always been designed to be supported by multiplehave always been designed to be supported by multipleimplementationsimplementations

    Compile to Machine CodeCompile to Machine Code

    Java has several solutions to compiling into machine code, thatJava has several solutions to compiling into machine code, that

    is when compiling to byte code is an issue for eitheris when compiling to byte code is an issue for either

    intellectual property or performance reasons.intellectual property or performance reasons.

  • 8/7/2019 6728719-Java

    9/43

    Contd.Contd.

    Future ProofFuture Proof

    Java is future proof or rather future portable, in the sense thatJava is future proof or rather future portable, in the sense that

    your existing code base will not become obsolete. How so? Iyour existing code base will not become obsolete. How so? I

    can run Java on machines today and machines in the future.can run Java on machines today and machines in the future.

    You don't have that assurance forMicrosoft's technologies likeYou don't have that assurance forMicrosoft's technologies like

    .NET..NET.

    Most Popular Language in the CorporationMost Popular Language in the Corporation

    A recentA recent surveysurvey reveals "Interestingly, the strong showing ofreveals "Interestingly, the strong showing of

    Visual C# .NET divides the Microsoft camp and propels JavaVisual C# .NET divides the Microsoft camp and propels Java

    into first place as the most popular language over the cominginto first place as the most popular language over the coming

    year".year".

  • 8/7/2019 6728719-Java

    10/43

    Contd.Contd.

    More Homogeneous and Less Complex EnvironmentMore Homogeneous and Less Complex Environment

    The Java environment is more homogeneous and less complexThe Java environment is more homogeneous and less complex

    than .NET. It is not littered with obsolete technologies likethan .NET. It is not littered with obsolete technologies like

    COM, DCOM, COM+, ADO, nor is it dependent on operatingCOM, DCOM, COM+, ADO, nor is it dependent on operatingsystem indiosyncracies like register settings or most recentsystem indiosyncracies like register settings or most recent

    service patch level.service patch level.

    Java IDEs are superior in their support for coding tasks.Java IDEs are superior in their support for coding tasks.

    Features like code refactoring, intention actions, superior codeFeatures like code refactoring, intention actions, superior code

    browsing (i.e Find Usages) and robust code completion arebrowsing (i.e Find Usages) and robust code completion are

    superior to what you find in Visual Studio.NET. In fact, Visualsuperior to what you find in Visual Studio.NET. In fact, Visual

    Studio.NET is known to unintentionally erase code.Studio.NET is known to unintentionally erase code.

  • 8/7/2019 6728719-Java

    11/43

    ContdContd..

    Cross Platform Integration with Other LanguagesCross Platform Integration with Other Languages

    Integration with Java from other languages like Perl, PHP orIntegration with Java from other languages like Perl, PHP or

    Python is cross platform. In otherwords, I can take my PHPPython is cross platform. In otherwords, I can take my PHP

    scripts that talk to Java and run in windows, place them in ascripts that talk to Java and run in windows, place them in aLinux box and have them work without a major porting effort.Linux box and have them work without a major porting effort.

  • 8/7/2019 6728719-Java

    12/43

    History ofJavaHistory ofJava

    Java started as a project called "Oak" byJava started as a project called "Oak" by James GoslingJames Gosling ininJune 1991 for use in a set top box project. Gosling's goals wereJune 1991 for use in a set top box project. Gosling's goals wereto implement ato implement a virtual machinevirtual machine and a language that had aand a language that had afamiliarC/C++ style of notation. The first publicfamiliarC/C++ style of notation. The first publicimplementation was Java 1.0 in 1995. It promised "implementation was Java 1.0 in 1995. It promised "WriteWriteOnce, Run AnywhereOnce, Run Anywhere" (WORA), providing no" (WORA), providing no--cost runtimescost runtimeson popular platforms. It was fairly secure and its security wason popular platforms. It was fairly secure and its security wasconfigurable, allowing network and file access to be restricted.configurable, allowing network and file access to be restricted.Major web browsers soon incorporated the ability to runMajor web browsers soon incorporated the ability to runsecure Java "secure Java "appletsapplets" within web pages. Java became popular" within web pages. Java became popular

    quickly. With the advent of "Java 2", new versions hadquickly. With the advent of "Java 2", new versions hadmultiple configurations built for different types of platforms.multiple configurations built for different types of platforms.

  • 8/7/2019 6728719-Java

    13/43

    Introduction to LanguageIntroduction to Language

    Java applicationsJava applications are typicallyare typically compiledcompiled toto bytecodebytecode, although, althoughcompilation to nativecompilation to native machine codemachine code is also possible. Atis also possible. Atruntimeruntime, bytecode is usually either, bytecode is usually eitherinterpretedinterpreted or compiled toor compiled tonative code for execution, although directnative code for execution, although direct hardwarehardware executionexecutionof bytecode by aof bytecode by a Java processorJava processoris also possible.is also possible.

    The language itself derives much of itsThe language itself derives much of its syntaxsyntax fromfrom CC andand C++C++but has a simplerbut has a simplerobject modelobject model and fewer lowand fewer low--level facilities.level facilities.JavaScriptJavaScript, a, a scripting languagescripting language, shares a similar name and has, shares a similar name and hassimilar syntax, but is not directly related to Java.similar syntax, but is not directly related to Java.

    Sun Microsystems provides aSun Microsystems provides a GNU General Public LicenseGNU General Public License

    implementation of a Javaimplementation of a Java compilercompilerand Javaand Java virtual machinevirtual machine,,in compliance with the specifications of thein compliance with the specifications of the Java CommunityJava CommunityProcessProcess, although the, although the class libraryclass library that is required to run Javathat is required to run Javaprograms is notprograms is not free softwarefree software..

  • 8/7/2019 6728719-Java

    14/43

    Primary goalsPrimary goals

    There were five primary goals in the creation of the JavaThere were five primary goals in the creation of the Javalanguage:language:

    It should use theIt should use the objectobject--oriented programmingoriented programming methodology.methodology.

    It should allow the same program to beIt should allow the same program to be executedexecuted on multipleon multipleoperating systemsoperating systems..

    It should contain builtIt should contain built--in support for usingin support for using computer networkscomputer networks..

    It should be designed to execute code fromIt should be designed to execute code from remote sourcesremote sourcessecurely.securely.

    It should be easy to use by selecting what was considered theIt should be easy to use by selecting what was considered thegood parts of other objectgood parts of other object--oriented languagesoriented languages

  • 8/7/2019 6728719-Java

    15/43

    Contd.Contd.

    In 1997, Sun approached theIn 1997, Sun approached the ISO/IECJTC1 standards bodyISO/IECJTC1 standards bodyand later theand later the Ecma InternationalEcma International to formalize Java, but it soonto formalize Java, but it soonwithdrew from the process.withdrew from the process.[5][5][6][6][7][7] Java remains a proprietaryJava remains a proprietaryde facto standard that is controlled through thede facto standard that is controlled through the JavaJavaCommunity ProcessCommunity Process..[8][8] Sun makes most of its JavaSun makes most of its Javaimplementations available without charge, with revenue beingimplementations available without charge, with revenue beinggenerated by specialized products such as the Java Enterprisegenerated by specialized products such as the Java EnterpriseSystem. Sun distinguishes between its Software DevelopmentSystem. Sun distinguishes between its Software DevelopmentKit (SDK) andKit (SDK) and Runtime Environment (JRE)Runtime Environment (JRE) which is a subsetwhich is a subsetof the SDK, the primary distinction being that in the JRE theof the SDK, the primary distinction being that in the JRE the

    compiler is not present.compiler is not present. OnOn November 13November 13,, 20062006, Sun released parts ofJava as, Sun released parts ofJava as

    freefree//open sourceopen source software, under thesoftware, under the GNU General PublicGNU General PublicLicenseLicense (GPL). The release of the complete(GPL). The release of the complete source codesource code underunderGPL is expected in the first half ofGPL is expected in the first half of20072007

  • 8/7/2019 6728719-Java

    16/43

    Platform independencePlatform independence

    One characteristic,One characteristic, platform independenceplatform independence, means that, means thatprogramsprograms written in the Java language must run similarly onwritten in the Java language must run similarly onany supported hardware/operatingany supported hardware/operating--system platform. Onesystem platform. Oneshould be able to write a program once, compile it once, andshould be able to write a program once, compile it once, andrun it anywhere.run it anywhere.

    This is achieved by most JavaThis is achieved by most Java compilerscompilers by compiling the Javaby compiling the Javalanguage code "halfway" tolanguage code "halfway" to bytecodebytecode simplified machinesimplified machineinstructions specific to the Java platform. The code is then runinstructions specific to the Java platform. The code is then runon aon a virtual machinevirtual machine (VM), a program written in native code(VM), a program written in native codeon the host hardware thaton the host hardware that interpretsinterprets and executes generic Javaand executes generic Java

    bytecode. (Further, standardized libraries are provided to allowbytecode. (Further, standardized libraries are provided to allowaccess to features of the host machines (such as graphics,access to features of the host machines (such as graphics,threadingthreading andand networkingnetworking) in unified ways. Note that, although) in unified ways. Note that, althoughthere is an explicit compiling stage, at some point, the Javathere is an explicit compiling stage, at some point, the Javabytecode is interpreted or converted to nativebytecode is interpreted or converted to native machinemachineinstructionsinstructions by theby the JIT compilerJIT compiler

  • 8/7/2019 6728719-Java

    17/43

    Automatic garbage collectionAutomatic garbage collection

    One of the ideas behind Java's automatic memory managementOne of the ideas behind Java's automatic memory managementmodel is that programmers be spared the burden of having tomodel is that programmers be spared the burden of having toperform manual memory management. In some languages theperform manual memory management. In some languages theprogrammer allocates memory for the creation of objectsprogrammer allocates memory for the creation of objectsstored on the heap and the responsibility of later deallocatingstored on the heap and the responsibility of later deallocatingthat memory thus resides with the programmer. If thethat memory thus resides with the programmer. If theprogrammer forgets to deallocate memory or writes code thatprogrammer forgets to deallocate memory or writes code thatfails to do so, afails to do so, a memory leakmemory leakoccurs and the program canoccurs and the program canconsume an arbitrarily large amount of memory. Additionally,consume an arbitrarily large amount of memory. Additionally,if the program attempts to deallocate the region of memoryif the program attempts to deallocate the region of memory

    more than once, the result is undefined and the program maymore than once, the result is undefined and the program maybecome unstable and may crash. Finally, in non garbagebecome unstable and may crash. Finally, in non garbagecollected environments, there is a certain degree of overheadcollected environments, there is a certain degree of overheadand complexity of userand complexity of user--code to track and finalize allocations.code to track and finalize allocations.Often developers may box themselves into certain designs toOften developers may box themselves into certain designs toprovide reasonable assurances that memory leaks will notprovide reasonable assurances that memory leaks will not

    occur.occur.

  • 8/7/2019 6728719-Java

    18/43

    Contd.Contd.

    In Java, this potential problem is avoided byIn Java, this potential problem is avoided by automaticautomaticgarbage collectiongarbage collection. The programmer determines when. The programmer determines whenobjects are created, and the Java runtime is responsibleobjects are created, and the Java runtime is responsiblefor managing thefor managing the object's lifecycleobject's lifecycle. The program or other. The program or other

    objects can reference an object by holding a referenceobjects can reference an object by holding a referenceto it (which, from a lowto it (which, from a low--level point of view, is its addresslevel point of view, is its addresson the heap). When no references to an object remain,on the heap). When no references to an object remain,the Java garbage collector automatically deletes thethe Java garbage collector automatically deletes theunreachable objectunreachable object, freeing memory and preventing a, freeing memory and preventing a

    memory leak. Memory leaks may still occur if amemory leak. Memory leaks may still occur if aprogrammer's code holds a reference to an object that isprogrammer's code holds a reference to an object that isno longer neededno longer neededin other words, they can still occurin other words, they can still occurbut at higher conceptual levels.but at higher conceptual levels.

  • 8/7/2019 6728719-Java

    19/43

    SyntaxSyntax

    The syntax ofJava is largely derived from C++. However,The syntax ofJava is largely derived from C++. However,

    unlike C++, which combines the syntax for structured, generic,unlike C++, which combines the syntax for structured, generic,

    and objectand object--oriented programming, Java was built exclusivelyoriented programming, Java was built exclusively

    as an object oriented language. As a result, almost everythingas an object oriented language. As a result, almost everything

    is an object and all code is written inside a class. Theis an object and all code is written inside a class. The

    exceptions are the intrinsic data types (ordinal and realexceptions are the intrinsic data types (ordinal and real

    numbers, boolean values, and characters), which are notnumbers, boolean values, and characters), which are not

    classes for performance reasons.classes for performance reasons.

  • 8/7/2019 6728719-Java

    20/43

    Example:Hello worldExample:Hello world

    public class Hellopublic class Hello

    {{public static void main(String[] args)public static void main(String[] args)

    {{

    System.out.println("Hello, World!");System.out.println("Hello, World!");

    }}

    }}

  • 8/7/2019 6728719-Java

    21/43

    An example that better demonstratesAn example that better demonstrates objectobject--orientedoriented

    programmingprogramming::

    // OddEven.java// OddEven.java

    import javax.swing.JOptionPane;import javax.swing.JOptionPane;

    public class OddEven {public class OddEven {

    private int input; public OddEven() {private int input; public OddEven() {input =input =integer.parseInt(JOptionPane.showInputDialog("integer.parseInt(JOptionPane.showInputDialog("Please Enter A Number")Please Enter A Number")

    ); }); }public void calculate() {public void calculate() {

    if (input % 2 == 0)if (input % 2 == 0)

  • 8/7/2019 6728719-Java

    22/43

    Odd evenOdd even

    System.out.println("Even");System.out.println("Even");

    elseelse

    System.out.println("Odd");System.out.println("Odd"); }}

    public static void main(String[] args)public static void main(String[] args)

    { OddEven number = new OddEven();{ OddEven number = new OddEven();

    number.calculate();number.calculate();

    }}}}

  • 8/7/2019 6728719-Java

    23/43

    Types of JavaTypes of Java

    There are many types ofJava programs whichThere are many types ofJava programs whichrun differently:run differently:

    AppletApplet -- can be put online (in web browsers).can be put online (in web browsers).

    ApplicationApplication -- can only be run on the computer,can only be run on the computer,cannot be put online.cannot be put online.

    ServletServlet -- runs on aruns on a serverserverand helps to displayand helps to display

    web pages.web pages. Swing applicationSwing application -- like an application, but canlike an application, but can

    have a more graphical lookhave a more graphical look..

  • 8/7/2019 6728719-Java

    24/43

    AppletApplet

    Java applets are programs that areJava applets are programs that areembedded in other applications, typicallyembedded in other applications, typicallyin a Web page displayed in ain a Web page displayed in a Web browserWeb browser

  • 8/7/2019 6728719-Java

    25/43

    Example of appletExample of applet

    import java.applet.Applet;import java.applet.Applet;

    import java.awt.Graphics;import java.awt.Graphics;

    public class Hello extends Applet {public class Hello extends Applet {public void paint(Graphics gc) {public void paint(Graphics gc) {g.drawString("Hello, world!", 65, 95);g.drawString("Hello, world!", 65, 95);

    }}}}

  • 8/7/2019 6728719-Java

    26/43

    CriticismCriticism

    PerformancePerformance

    Java's performance has increased substantially sinceJava's performance has increased substantially since

    the early versions, and performance ofthe early versions, and performance ofJIT compilersJIT compilers

    relative to native compilers has in some tests beenrelative to native compilers has in some tests beenshown to be quite similar.The performance of theshown to be quite similar.The performance of the

    compilers does not necessarily indicate thecompilers does not necessarily indicate the

    performance of the compiled code; only carefulperformance of the compiled code; only careful

    testing can reveal the true performance issues in anytesting can reveal the true performance issues in any

    systemsystem

  • 8/7/2019 6728719-Java

    27/43

    Look and feelLook and feel

    The defaultThe default look and feellook and feel ofofGUIGUI applications written in Javaapplications written in Javausing theusing the SwingSwing toolkit is very different from nativetoolkit is very different from nativeapplications. It is possible to specify a different look and feelapplications. It is possible to specify a different look and feelthrough thethrough the pluggable look and feelpluggable look and feel system of Swing. Clonessystem of Swing. Clones

    ofofWindowsWindows,, GTKGTKandand MotifMotifare supplied by Sun.are supplied by Sun. AppleApple alsoalsoprovides anprovides an AquaAqua look and feel forlook and feel forMac OS XMac OS X. Though prior. Though priorimplementations of these look and feels have been consideredimplementations of these look and feels have been consideredlacking, Swing in Java SE 6 addresses this problem by usinglacking, Swing in Java SE 6 addresses this problem by usingmore nativemore native widgetwidget drawing routines of the underlyingdrawing routines of the underlying

    platforms. Alternatively, third party toolkits such asplatforms. Alternatively, third party toolkits such as wx4jwx4j ororSWTSWT may be used for increased integration with the nativemay be used for increased integration with the nativewindowing systemwindowing system

  • 8/7/2019 6728719-Java

    28/43

    Lack of OO purityLack of OO purity

    Java'sJava's primitive typesprimitive types are not objects. Primitive types storeare not objects. Primitive types store

    their values in thetheir values in the stackstackrather than being references to values.rather than being references to values.

    This was a conscious decision by Java's designers forThis was a conscious decision by Java's designers for

    performance reasons. Because of this, Java is not considered toperformance reasons. Because of this, Java is not considered to

    be a pure objectbe a pure object--oriented programming language. However, asoriented programming language. However, as

    ofJava 5.0,ofJava 5.0, autoboxingautoboxing enables programmers to write as ifenables programmers to write as if

    primitive types are their wrapper classes, and freelyprimitive types are their wrapper classes, and freely

    interchange between them for improved flexibilityinterchange between them for improved flexibility

  • 8/7/2019 6728719-Java

    29/43

    ResourcesResources

    Java Runtime Environment:Java Runtime Environment: TheThe Java RuntimeJava RuntimeEnvironmentEnvironment ororJREJRE is the software required to run anyis the software required to run anyapplicationapplication deployed on the Java Platform.deployed on the Java Platform. EndEnd--usersuserscommonly use a JRE incommonly use a JRE in software packagessoftware packages and Web browserand Web browserpluginsplugins. Sun also distributes a superset of the JRE called the. Sun also distributes a superset of the JRE called theJava 2Java 2 SDKSDK(more commonly known as the JDK), which(more commonly known as the JDK), whichincludes development tools such as theincludes development tools such as the Java compilerJava compiler,,JavadocJavadoc, and, and debuggerdebugger..

    One of the unique advantages of the concept of a runtimeOne of the unique advantages of the concept of a runtimeengine is that errors (exceptions) should not 'crash' the system.engine is that errors (exceptions) should not 'crash' the system.

    Moreover, in runtime engine environments such as Java thereMoreover, in runtime engine environments such as Java thereexist tools that attach to the runtime engine and everytime thatexist tools that attach to the runtime engine and everytime thatan exception of interest occurs they record debuggingan exception of interest occurs they record debugginginformation that existed in memory at the time the exceptioninformation that existed in memory at the time the exceptionwas thrown (stack and heap values). These tools are calledwas thrown (stack and heap values). These tools are calledExceptionException

  • 8/7/2019 6728719-Java

    30/43

    Contd.Contd.

    Interception or Error Interception tools and theyInterception or Error Interception tools and they

    provide 'rootprovide 'root--cause' information for exceptions incause' information for exceptions in

    Java programs that run in production, testing orJava programs that run in production, testing or

    development environmentsdevelopment environments

  • 8/7/2019 6728719-Java

    31/43

    APIsAPIs

    Sun has defined three platforms targeting differentSun has defined three platforms targeting differentapplication environments and segmented many of itsapplication environments and segmented many of itsAPIsAPIs so that they belong to one of the platforms. Theso that they belong to one of the platforms. Theplatforms are:platforms are:

    Java Platform, Micro EditionJava Platform, Micro Edition (Java ME)(Java ME) targetingtargetingenvironments with limited resources,environments with limited resources,

    Java Platform, Standard EditionJava Platform, Standard Edition (Java SE)(Java SE) targeting workstation environments, andtargeting workstation environments, and

    Java Platform, Enterprise EditionJava Platform, Enterprise Edition (Java EE)(Java EE) targeting large distributed enterprise or Internettargeting large distributed enterprise or Internetenvironments.environments.

  • 8/7/2019 6728719-Java

    32/43

    JSMSJSMS

    Open up the world of "Mobile Messaging" to our Java

    application. Using jSMS, our application is

    quickly enabled to send and receive mobile short

    messages (SMS).

  • 8/7/2019 6728719-Java

    33/43

    Software Architecture

    The jSMS SDK does not contain any native code and cantherefore be run on all available Java2 platforms(e.g.Solaris, Linux, Windows). When using a GSMdevice,yourJava Platform must also supply an implementation ofjavax.comm (Java Communications API).The jSMS

    programming interface has been designed to beindependent of the underlaying protocol. You can easilyswitch from one transport facility to another one, withoutneeding to change your your application. The jSMSLibrary requires only 180KB and can therefore also be

    used in Embedded Devices.

  • 8/7/2019 6728719-Java

    34/43

    ConnectivityjSMS supports the most widespread protocols used today for

    mobile messaging. Accessing the mobile network can be achieved

    by using a GSM device (e.g. a Mobile Phone), a modem

    connection or the Internet (TCP/IP).

  • 8/7/2019 6728719-Java

    35/43

    jSMS supported protocols

    GSM 03.38, 03.40 & 07.05 (GSM Devices with a built-inModem)

    UCP (Universal Computer Protocol)

    CIMD2 (Computer Interface to Message Distribution)

    SMPP (Short Message Peer-to-Peer Protocol) TAP/IXO (Paging Protocol)

    MM1 (Multimedia Messaging using WAP/WAP PUSH andGPRS)

    MM7 (Multimedia Messaging for Value Added Service

    Providers)

  • 8/7/2019 6728719-Java

    36/43

    Message Types

    7-Bit Text -max. 160 Characters /Message

    UCS2 (Unicode) Universal Character Set -

    (e.g. for SimplifiedC

    hinese) Binary Data (8-Bit) - max. 80 Bytes /Message

    SmartMessages -Business Cards, Calendar

    Entries,O

    perator Logos, PictureMessages,Ringtones

    Status Reports

  • 8/7/2019 6728719-Java

    37/43

    Message and Sms Message

    The base class for all messages (exceptMMS) in thejSMS API is called Message. A Message object canbe sent as an SMS (by using one of the SmsService

    implementations) or as an email (using theSmtpService). If you want to have more control aboutthe content and attributes of a SMS Message, theclass SmsMessage should be used. SmsMessageextends the base Message class and adds additional

    features like specifying the message's characterencoding (alphabet), setting the validity period of themessage, requesting a status report, etc.

  • 8/7/2019 6728719-Java

    38/43

    Example Code for smsExample Code for sms

    importimport com.objectxp.msg.*;com.objectxp.msg.*;public classpublic class SendSMS {SendSMS {

    public staticpublic static voidvoid main(String args[]) {main(String args[]) {

    trytry { //Create and initialize a SMS service{ //Create and initialize a SMS service

    SmsService service =SmsService service = newnew GsmSmsService();GsmSmsService();service.init();service.init();

    service.connect(); //Create a new SMS Messageservice.connect(); //Create a new SMS Message

    SmsMessage msg =SmsMessage msg = newnew SmsMessage(service);SmsMessage(service);

    // Set recipient and message// Set recipient and message

    msg.setRecipient("0791243657");msg.setRecipient("0791243657");

    msg.setMessage("SYS1: Power loss. Shutdown in 5msg.setMessage("SYS1: Power loss. Shutdown in 5minutes.");minutes.");

  • 8/7/2019 6728719-Java

    39/43

    ctdctd

    msg.requestStatusReport(true);msg.requestStatusReport(true);

    // Send the SMS// Send the SMSservice.sendMessage(msg);service.sendMessage(msg);

    System.out.println("Message sent successfuly, ID isSystem.out.println("Message sent successfuly, ID is

    "+msg.getMessageId());"+msg.getMessageId());

    service.disconnect(); }service.disconnect(); }

    catch( MessageException me ) {catch( MessageException me ) {

    System.out.println("Message could not be sent:System.out.println("Message could not be sent:

    "+me.getMessage());"+me.getMessage());

    }}

    finally { if( service != null ) {finally { if( service != null ) {service.destroy(); // Destroy the service } }service.destroy(); // Destroy the service } }

    }}}}

    M lti di M S i

  • 8/7/2019 6728719-Java

    40/43

    Multimedia Message Service

    (MMS)

    Currently,jSMS provides a implementation for the

    following protocol(s):

    MM1 (WSP/WTP using WAP-PUSH and a PPP

    connection)

    MM7 (Multimedia Messaging for Value Added

    Service Providers (VASP))

    The MMS Service interface defines the methods tosend and receive a MultimediaMessage (MMS)

    to/from a MMS-Proxy/Relay.

  • 8/7/2019 6728719-Java

    41/43

    ApplicationsApplications

    Possible ApplicationsPossible Applications

    AlarmingAlarming

    Remote ControlRemote Control

    MonitoringMonitoring

    NotificationNotification

    MarketingMarketing

    News servicesNews services

  • 8/7/2019 6728719-Java

    42/43

    KeywordsKeywords

    GSM (Global System for Mobile Communications):

    The most widely used communication protocol. GSM

    is used generally for mobile telephone calls. GSM

    enables 9.6 Kbps data transfer rate. GPRS (General Packet Radio Service): GPRS allows

    users to be connected to the network at all times.

    GPRS transfer rate is between 30 and 100 Kbps and

    only the traffic generated by the user is billed.

  • 8/7/2019 6728719-Java

    43/43

    References:References:

    http:// www.objectxp.com /

    http :// java.sun.com /products/ javacomm /

    index.html

    http ://www.wikipedia.com

    The Complete Reference-Java by Herbert Shildt

    Programming with Java: E.Balagurusamy

    Teach yourselfJava: Joseph ONeil Core Java: Gary Cornell