Sunday, June 30, 2013

Creating executable Jar files

    To make an executable jar file, one must have a .java file, let's create one sample:

Create a folder of some name and create the java file in there, so as to avoid confusion

HelloWorld.java


public class HelloWorld {

public static void main(String[] args) {

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

}
}

save it with.java extension, now we have HelloWorld.java

now open cmd from Run > cmd, hit enter

compile the java class, so to create a .class file like this:


Now we have a class file created in the drive, now create a manifest file with name like manifest.txt, this is a text file.

write in this txt (notepad) file, 

Main-Class: HelloWorld

In this file, HelloWorld is the name of Class that contains the main method, also hit enter in notepad after writing class name like this:



Now we have these files:

1. .java file
2. .class file
3. manifest file

now open the cmd and run this command in the folder that contains the java file, .class file, manifest file

jar cfm some_name.jar manifest.txt HelloWorld.class

you can use any name for the jar file that you are gonna create as long as there is a .jar after the name, when you hit enter it must not show any error like this:



 it must create a .jar file in the folder like this:


now if you double click this file it will not show you anything

right click on this file and open this file with winrar or some compression software, you may see something like this:


 Open the test.jar with winrar and it must show these files, the .class file and META-INF folder

Open META-INF folder and you'll see


open this file with notepad, like this:


and you'll see this:


After making sure these things are right, go to cmd and execute the following command:

java -jar test.jar

and this will print "Hello World", which is present in the java file


This is what we used in println in the java file, now the jar is ready and is executable.


Monday, March 11, 2013

Web Services


         Web services is nothing but a resource through which you can convert your application into web application, also it helps data transfer between various platforms and applications and the most recommended format of transferring data is XML. XML has been recognized by W3C to be used exclusively for web services, in other words data is carried out in XMLs.
        Web services basically consists of three elements :
1. SOAP
2. WSDL
3. UDDI

SOAP : SOAP is Simple Object Access Protocol, which enables the transfer of data between various platforms and different languages, so this becomes the main part of web services. It uses HTTP protocol for the transfer of data.
SOAP basically consists of 
  • Envelope
  • Header
  • Body
  • Fault
Envelope : Envelope is the root element of the SOAP message, it consists soap:xmlns namespace which has default value of : 
    ---------------------------------------------------------------------------
    "http://www.w3.org/2001/12/soap-envelope"
    ---------------------------------------------------------------------------

    Example :
    ---------------------------------------------------------------------------------------------------------

    <?xml version="1.0"?>

    <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
    soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
    ............
    Messages that you want to transfer
    ............
    </soap:Envelope>
    ---------------------------------------------------------------------------------------------------------

    If any namespace other than soap:xmlns is used, it will not allow the transfer and generate an error.

    SOAP encoding Style attribute : It is the basic encoding style used in the SOAP
    soap:encodingStyle="URI".

    Header : Header is the first element of Envelope element in the SOAP message. It contains three attributes : 
    • mustUnderstand
    • actor
    • encodingStyle
    Body : This contains the actual message that will be transferred.

    ------------------------------------------------------------------------------------------------------------
    <?xml version="1.0"?>
    <soap:Envelope
    xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
    soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

    <soap:Body>
      <m:GetPrice xmlns:m="http://www.w3schools.com/prices">
        <m:Item>Apples</m:Item>
      </m:GetPrice>
    </soap:Body>

    </soap:Envelope>

    ------------------------------------------------------------------------------------------------------------

    Fault : It is an optional element and it is used to indicate error messages.


    WSDL : Web Services Description Language, is other part of web services which is used to locate and describe the application that is converted into web application. It's simply a link that takes you to the application, in other words you convert the data that is inter-operable between different platforms using SOAP and WSDL takes you to that data.

    UDDI : Universal Description, Discovery and Intergration, is a kind of directory for storing the information about web services it transfers data via SOAP.

    If you want to learn more about Web Services refer : 

    http://w3schools.com/webservices/ws_why.asp

    Friday, March 1, 2013

    Things that you must look while buying an Android

                         Android had and had been a better Operating system for mobiles, but it all depends on the better hardware that you have with you like RAM, Internal Memory etc. There are many good smartphone companies releasing phones, when you are not sure about requirements make sure what you are going to use your smartphone for, if you want to go for social networking, smartphone with less RAM and internal memory would suffice, but you will have to sacrifice the performance, if you aim at performance, graphics and have the desire to explore whole lot of new applications, I would recommend you go for a higher RAM and internal memory. For better performance I would recommend a minimum of 500MB RAM and an internal memory of at least 1 GB.

    If you want to go with high price I would recommend : 

    Samsung Note II

    Samsung Galaxy S III

    If you want to go with moderate price, I would recommend:  

    HTC Desire V

    Samsung Galaxy S Advance

    If you want to go with low price I would recommend : 

    Sony Xperia Miro

    Sony Xperia Neo L

    Comments

    blog comments powered by Disqus