Pages

Monday, 28 November 2016

Java Environment Setup : Getting Started




In this tutorial we will discuss about the how to set Java Environment Setup to your machine. 

however i have already discussed about Environment setup in this post but then also i am showing you the easy way to do all this ... so lets start.. 
Environmental variables are used by the operating system to save settings (default values, locations of resources) to be used by Windows or by processes launched by users.
There are two types of environmental variables:
  1. user variables that are specific to a particular Windows user account;
  2. system variables are always visible, regardless of the used user account.
Even if these variables are usually defined and initialized automatically when you install the system or other applications, there are situations in which the user must manually define them to put at the disposal of applications.

Please follow the following steps to set up the environment.
Step 1: Download the Java Development Kit (JDK). You can download it here

Step 2: Follow the instructions and install the JDK.

Step 3: Right-click on 'My Computer' and select 'Properties'. 

Step 4: Click on Advanced system settings. A dialog box appears. 

Step 5: Click on the Environment Variables button at the bottom-right of the System Properties dialog box.

Step 6: A dialog box named Environment Variables appears. Click on the TEMP variable in the User variables section. Now go down to the “Path” variable in the System Variables section and click on edit.  

Step 7: The Edit System Variable dialog appears. At the end of the Variable value section append a semi-colon and then enter the path of the bin directory of you JDK. To copy the path of the bin directory follow the picture below 



Step 8: Then paste the path on the field as shown below. Make sure you have appended a semi-colon before you paste the address.



Step 9: Then click on OK as shown and then you are done. To confirm whether your settings are right, open command prompt and type “javac”. You should get a response like this on your prompt.




Step 10: Type ”java” and you should get something like this.





If all of the above steps are followed correctly, you will be able to setup your java compiler and you can now start programming.

Popular Java Editors:

To write your java programs you will need a text editor. There are even more sophisticated IDE available in the market. But for now, you can consider one of the following:

Notepad : On Windows machine you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.

Netbeans :is a Java IDE that is open source and free which can be downloaded from http://www.netbeans.org/index.html.

Eclipse : is also a java IDE developed by the eclipse open source community and can be downloaded from http://www.eclipse.org/.



Hope you have set up java properly ,you have to because without this you can not run your java program .........


ba...bayeeee.......





Java Basic Syntax : Java Basic




Java Basic Syntax : Java Basic







Hello Before knowing anything in java you must know basic syntax of java .
after that we are ready to create our first program..... how amazing it will be ....!!!

Basic Syntax:

About Java programs, it is very important to keep in mind the following points.

Case SensitivityJava is case sensitive which means identifier Hello and hello would have different meaning in Java.

Class NamesFor all class names the first letter should be in Upper Case.

If several words are used to form a name of the class each inner words first letter should be in Upper Case.

Example class MyFirstJavaClass

Method NamesAll method names should start with a Lower Case letter.

If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case.

Example public void myMethodName()

Program File Name - Name of the program file should exactly match the class name.

When saving the file you should save it using the class name (Remember java is case sensitive) and append '.java' to the end of the name. (if the file name and the class name do not match your program will not compile).

Example : Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as 'MyFirstJavaProgram.java'

public static void main(String args[]) - java program processing starts from the main() method which is a mandatory part of every java program.


Java Identifiers:All java components require names. Names used for classes, variables and methods are called identifiers.
In java there are several points to remember about identifiers. They are as follows:
  • All identifiers should begin with a letter (A to Z or a to z ), currency character ($) or an underscore (-).
  • After the first character identifiers can have any combination of characters.
  • A key word cannot be used as an identifier.
  • Most importantly identifiers are case sensitive.
  • Examples of legal identifiers:age, $salary, _value, __1_value
  • Examples of illegal identifiers : 123abc, -salary
Java Modifiers:
Like other languages it is possible to modify classes, methods etc by using modifiers. There are two categories of modifiers.
  • Access Modifiers : defualt, public , protected, private
  • Non-access Modifiers : final, abstract, strictfp
We will be looking into more details about modifiers in the next section.

Java Variables:

We would see following type of variables in Java:
  • Local Variables
  • Class Variables (Static Variables)
  • Instance Variables (Non static variables)

Java Arrays:
Arrays are objects that store multiple variables of the same type. However an Array itself is an object on the heap. We will look into how to declare, construct and initialize in the upcoming chapters.

Java Datatypes:

There are  8 types of Datatypes :
1-byte
2-short
3-int
4-long
5-float
6-double
7-boolean
8-char
Java Keywords:

The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names.
abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile



Comments in Java:

Java supports single line and multi-line comments very similar to c and c++. All characters available inside any comment are ignored by Java compiler.
public class MyFirstJavaProgram{

   /* This is my first java program.
    * This will print 'Hello World' as the output
    * This is an example of multi-line comments.
    */

    public static void main(String []args){
       // This is an example of single line comment
       /* This is also an example of single line comment. */
       System.out.println("Hello World"); 
    }
} 

Using Blank Lines:

A line containing only whitespace, possibly with a comment, is known as a blank line, and Java totally ignores it.

Inheritance:
In java classes can be derived from classes. Basically if you need to create a new class and here is already a class that has some of the code you require, then it is possible to derive your new class from the already existing code.

This concept allows you to reuse the fields and methods of the existing class with out having to rewrite the code in a new class. In this scenario the existing class is called the super class and the derived class is called the subclass.

Interfaces:

In Java language an interface can be defined as a contract between objects on how to communicate with each other. Interfaces play a vital role when it comes to the concept of inheritance.

An interface defines the methods, a deriving class(subclass) should use. But the implementation of the methods is totally up to the subclass.



i hope you now know some basic syntax of java ,this will really need to understand the java program which we will see in the next post.... 

ba.. bayeeeee.......


Sunday, 27 November 2016

What Is Java?

What Is Java?


What Is Java ?
Hello friend Are you also confused about java ,what exactly it is and how it is different from other languages like c/c++  , so today i am going to tell you everything about java .....


so grab your java coffee mug and listen....... 



Java is a general-purpose, concurrent, class-based, object-oriented computer programming language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. Java is, as of 2012, one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users.Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.


What is J2SE?
J2SE is a collection of Java Programming Language API (Application programming interface) that is very useful to many Java platform programs. It is derived from one of the most dynamic programming language known as "JAVA". Java is the creation of Sun Microsystems. and one of its three basic editions of Java known as Java standard edition being used for writing Applets and other web based applications.

Java has advanced through the years in both functionality and reach. Current editions are on the Java 2 Platform. The Java 2 Platform has various incarnations as well, including Java 2 Platform.

The Java 2 Platform has three basic Editions-
1. Java 2 Standard Edition (J2SE): J2SE is used primarily for writing applets and other Java-based applications.
Example: Music Player , Antivirus, etc..
2. Java 2 Enterprise Edition (J2EE): J2EE is the Java architecture for developing multitier enterprise applications. As part of J2EE, JSP pages have access to all J2EE components, including JavaBeans and Enterprise JavaBeans components and Java servlets. JSP pages are actually compiled into servlets, so they have all of the benefits of these flexible, server-side Java applications.
Example : Banking Applications.
3. Java 2 Micro Edition (J2ME): J2ME is a technology that allows programmers to use the java programming language and related tools to develop programs for mobile wireless information devices such as cellular phones and personal digital assistants (PDAs).
now J2ME is not used much because of android OS which also use Java for its development .
Example : 
1-Symbian(Java base OS used in older phones),
2-Android (you know very well,it is top in the market now)



Where it is used?
According to Sun, 3 billion devices run java. There are many devices where java is currently used. Some of them are as follows:

  1. Desktop Applications such as acrobat reader, media player, antivirus etc.
  2. Web Applications such as irctc.co.in, magicbricks.com etc.
  3. Enterprise Applications such as banking applications.
  4. Mobile
  5. Embedded System
  6. Smart Card
  7. Robotics
  8. Games etc.
Java Application Types-
There are different types of Java applications before moving on to Servlets.
Java can be used to develop different types of applications:
  1. Standalone Applications (Music Player,Antivirus)
  2. Applets ( outdated now)
  3. Web Applications 
  4. Distributed Applications (Banking Application)

Standalone Applications-
A standalone application is a program that runs on your computer. It is more or less like a C or C++ program.

Applets-
An applet is an application designed to travel over the Internet and to be executed on the client machine by a Java-Compatible web browser like Internet Explorer or Netscape. Applets are also Java programs but they reside on the servers. An applet can not be executed like standalone application. Applet can be executed only by embedding it into an HTML page like an image or sound file. To run an applet you need to access an HTML page which has applet embedded into it. When the web browser downloads such an HTML page, it subsequently loads the executable file, which contains Applet and then executes it on the local machine.
(outdated now)
Web Applications-
Web applications run on the Web Server. Web applications are accessed through web clients i.e. web browsers like Internet Explorer or Netscape. Whenever you access some web site by specifying the URL (Universal Resource Locator), you are accessing some web application. The main components of a web application written in Java are:

Java Servlets
Java Server Pages (JSP), and
HTML

Java Servlets are also Java programs, which run on the Server and then send the result/response to the client. JSP pages can be thought of as a combination of HTML and Java Code. The Web Server converts JSP pages into Java Servlets before execution.

You access the web application by specifying the URL. If the URL corresponds to an HTML page the web server simply returns the HTML page to the client, which then displays it. If the URL corresponds to the Servlet or JSP then it is executed on the Server and the result/response is returned to the client, which is then displayed by the client.

Distributed Applications-
Java application can be divided into a number of modules/components (Java programs), which can run on different machines. The Java programs/applications running on different machines can communicate with each other. To be more precise the Java Objects on one machine can invoke methods on the Java Objects running on another machine. Thus Java has the support for the distributed processing in the language itself.


so i hope now you know what java is and ready !!!!

ba bayee see you in the next post.........wheeeeeeeeeeeeeeeeeeeee......





History of Java

History of Java


Bello  !!!!!!!


I know we are not interested in knowing the History of java and just want to learn java and want to become a java developer as soon as possible  , of course there is no need to read about history of java to learn java but if you want to make java mix in your soul and breath you should read about its past to know at least where it all started . So my dear readers here presenting  the history of JAVA .. tan tan tadeeenn....

once upon a time....

In 1990, Sun Microsystems Inc. (US) has conceived a project to develop software for  "consumer electronic" devices that could be controlled by a remote. This project was called Stealth Project but later its name was changed to Green Project.






And the name of the team was "Green team"


Green Team :)


In Jan of 1991, Bill Joy, James Gosling, Mike Sheradin, Patrick Naughton and several others met in Aspen, Colorado to discuss this project. Mike Sheradin was focused on Business Development, Patrick Naughton worked on the Graphics systems and James Gosling was to identify the proper programming language for the project. Gosling thought C and C++ could be used to develop the project. But the problem he faced with them is that they were system dependent languages and hence could not be used various processors which the electronics devices might use. So he start to develop a new language which was completely system independent. This language was initially called as OAK


Oak Tree



 Since this name was registered by other company, later it was changed to JAVA



WHY THE NAME IS JAVA? James Gosling and his team members were consuming a lot of coffee while developing this language. They felt that they were able to develop a better language because of the good quality of coffee they consumed. So the coffee had its own role in developing this language and good quality of coffee was exported to the entire world from a place called 'JAVA ISLAND'. Hence they fixed the name of the place for the language as JAVA. And the symbol for JAVA Language is coffee cup and saucer.


---Coffee Time---




By September of 1994, Naughton and Jonathan Payne started writing WebRunner-a Java based Web browser, which was later renamed as HotJava. By October 1994, HotJava was stable and was demonstrated to Sun executives. HotJava was the first browser, having the capabilities of executing applets, which are programs designed to run dynamically on Internet. This time, Java's potential in the context of the World Wide Web was recognized. 

Sun formally announced Java and HotJava at SunWorld conference in 1995. Soon after, Netscape Inc. announced that it would incorporate Java support in its browser Netscape Navigater. Later, Microsoft also announced that they would support Java in their Internet Explorer Web browser.  

Java Versions:
There are many java versions that has been released. Current stable release of Java is Java SE 8.
  1. JDK Alpha and Beta (1995)
  2. JDK 1.0 (23rd Jan, 1996)
  3. JDK 1.1 (19th Feb, 1997)
  4. J2SE 1.2 (8th Dec, 1998)
  5. J2SE 1.3 (8th May, 2000)
  6. J2SE 1.4 (6th Feb, 2002)
  7. J2SE 5.0 (30th Sep, 2004)
  8. Java SE 6 (11th Dec, 2006)
  9. Java SE 7 (28th July, 2011)
  10. Java SE 8 (18th March, 2014)


so that was the history of java I hope you have enjoyed the tale , there are many tales about history of java but believe me this seems the real one .... any way have a good day ...
see you in the next post..   ba bayeee....!!!!