Wednesday, 22 June 2016

BASICS OF JAVA

ABOUT JAVA

○ Java is high level programming language.
○ It is based on the concept of OOP's.
○ It is widely used in computer programming language.
○ The application which develops in java is"write once, run anywhere".
○ It is platform independent (platform defines as a combination of particular hardware and software).
○ Java is a open source programming language.
○ Almost syntax taken from C or C++ and Java is case-sensitive.


HISTORY OF JAVA

○ Java is a programming language created by James Gosling from Sun Microsystem (Sun) in 1991.
○ The language was initially called Oak after an oak tree that stood outside Gosling's office.
○ Later the project went by the name Green and was finally renamed Java.
○ Gosling designed Java with a C/C++-style syntax that system and application programmers.
○ The target of Java is to write a program once and then run this program on multiple operating           systems.
○ The first publicly available version of Java (Java 1.0) was released in 1995.
○ Sun Microsystem was acquired by the Oracle Corporation in 2010.
○ In 2006 Sun started to make Java available under the GNU General Public License (GPL).
○ Oracle continues this project called OpenJDK.


PROPERTIES OF JAVA


Platform Independent.
(Platform is any hardware or software environment in which a program runs, is known as a platform. Since Java has its own runtime environment (JRE) and API, it is called platform.)
(OBJECT ORIENTED PROGRAMMING refers to a programming methodology based on objects, instead of just functions and procedures. These objects are organized into classes, which allow individual objects to be group together. Most modern programming languages including C,C++, C#, JAVA , PHP, etc are object-oriented languages)

Strongly-typed programming language.
(the types of the used variables must be pre-defined and conversion to other objects is relatively strict,)

Interpreted and compiled language.
(Java source code is transferred into the bytecode format which does not depend on the target platform)

○ Automatic memory management.
(Java has garbage collector,that automatically deletes objects which is not in scopes.)


FEATURES OF JAVA 


The Java language has some of best Features that makes java unstoppable, And these features are simple and easy to understand...

Simple ( syntax is based on C or C++)
◘ Object-Oriented (methodology that simplify software development)
◘ Platform independent (hardware or software environment in which a program runs)
◘ Secured (No pointer concepts and Programs run inside virtual machine)
◘ Robust (Robust means strong hence Java has strong memory management)
◘ Portable (run able in any platform)
◘ High Performance (fastly compiled and executed)
◘ Multi-threading (thread is a light weight process. In java a thread is like a separate program, executing concurrently)


JAVA EDITION

There are three types of java edition 

J2EE
- J2EE stands for JAVA ENTERPRISE EDITION.The Enterprise version of Java has a much larger usage of Java, like development of web services, networking, server side scripting and other various web based applications. 
J2EE uses HTML, CSS, JavaScript etc., so as to create web pages and web services.
 - J2EE is mainly used to create web application.

J2SE
- J2SE stands for JAVA STANDER-ED EDITION.
- Also known as Core Java, this is the most basic and standard version of Java.It’s the purest form of  Java, a basic foundation for all other editions.
- J2SE is mainly used to create applications for Desktop environment.

J2ME
- J2ME stands for JAVA MICRO EDITION or JAVA MOBILE EDITION
- J2ME mainly concentrated for the applications running on embedded systems,  mobiles and small devices.
- J2ME is mainly used to create  mobile applications.



TYPE OF JAVA APPLICATION


There are many devices where java is currently used. Some of them are as follows:

♣ Desktop Applications
♣ Web Applications
♣ Enterprise Applications
♣ Mobile
♣ Embedded System
♣ Smart Card
♣ Robotics
♣ Games  etc.


BASIC TERMS

JVM
- JVM stands for java virtual machine. 
- Java program execution uses a combination of compilation and interpretation. Programs written in Java are compiled into machine language, but it is a machine language for a computer that is, virtual and doesn't really exist. This so-called "virtual" computer is known as the Java virtual machine (JVM)

JRE
JRE is an implementation of the JVM which actually executes Java programs. It includes the JVM, core libraries and other additional components to run applications and applets written in Java.
JDK


Java Development Kit (JDK) is a bundle of software components that is used to develop Java based applications.


It includes -

  1. Java Compiler * 
  2. Java Interpreter * 
  3. Java Dis - assembler 
  4. Java Header File Generator 
  5. Java Documentation * 
  6. Java Debugger 
  7. Java Applet Viewer * 
(* these are use able terms...)

BYTE CODE
The machine language for the Java virtual machine is called Java bytecode.
After compilation java source code generate java byte code(it is like a machine code and understandable by user)


REQUIREMENTS (ENVIRONMENT SETUP)

THE JAVA PROGRAM IS COMPILED BY TWO WAYS---
1- USING NOTEPAD (TEXT EDITOR)
2- by COMPILER likes (eclipse , net beans , bluej etc).

NOTE-Before that you have to download jdk click here to download 



STRUCTURE OF JAVA PROGRAM



class Hr {
public static void main(String args [ ]){
System.out.println("Hackers Rocks");
}
}


*USING NOTE PAD*


1-Open note pad (other text editor like Notepad++)
2-copy paste above program (code)
3-Save your file as Hr.java in desktop. (Note-save same name as class name and file name)
4-To make sure your file name is Hr.java, (not in Hr.java.txt), first choose "Save as file type:" All files, then type in the file name Hr.java.
5-Run Command Prompt .

C:\Users\somesh> cd Desktop

C:\Users\somesh\Desktop> javac Hr.java

C:\Users\somesh\Desktop> java Hr




You should see the program output:Hacker Rocks

javac stands fot java compiler
java runs your program










If the system cannot find javac, check the set path command. for that watch the video ..



Note-watch this after 1:10 minutes



*USING COMPILER*

I  suggest you to use BlueJ as beginner .
Afterwords, use netbeans or eclipse as they are widely used in multinational company to develop java applications.

  • open BlueJ
  • click on "New Class"
  • new window open , 
  • enter class name then, now hit enter.
  • now new window open 
  • copy and paste above code
  • right click on icon of your class name
  • click on compile
  • click on void main (String [] args)  to run.
  • new windows , and you can able to see your output in that opened window.







BOOKS 


1- Java: The Complete Reference,

2- Java: A Beginner’s Guide,

3- Thinking in Java

4- Head First Java, (Best book but not for beginners)





Also Read:-

No comments:

WINDOWS SUBSYSTEM FOR LINUX

Microsoft partnered with Canonical (creator of Ubuntu) to bring Linux environment experience in Windows 10. Through Windows Subsystem F...