Java is object oriented and platform independent programming language which runs upon JVM. If you are newbie with programming then you will have following questions:
- What is programming?
- What is platform independent and JVM ?
- What is object oriented programming?
- What is object?
Program is collection of statements which preform any task on machine. Programming languages are human readable. These are compiled by compilers to convert into assembly language which is readable by machine. Java runs upon Java Virtual Machine (JVM). It is a virtual environment and similar to .NET platform. Due to JVM, java does not depends on operating system like C and C++. It can run on any platform (linux, windows, mac, etc. ). Object oriented programming is object based programming. Everything is an object. You can take any conceptual component in the problem you’re trying to solve (house, table, chair, etc.) and represent it as an object in your program. In a program there are a lot of objects which tell each other what to do by sending messages. Each object has its own memory.
Why Java?
- Object Oriented: Java is most object oriented.
- Platform independent: It runs on JVM.
- Simple:Java is designed to be easy to learn. Its syntax is similar to C and C++.
- Secure: Java enables to develop tamper-free andvirus-free systems. Authentication techniques are based on public-key encryption.
- Architectural-neutral: Java compiler generates an architecture-neutral object file format, which makes the compiled code to be executable on many processors, with the presence of Java runtime system.
- Portable: Compiler in Java is written in ANSI C with a clean portability boundary which is a POSIX subset.
- Multithreaded: It is possible to write programs that can do many tasks simultaneously.
Prerequisites:
1) Install Java
2) Install Java IDE like ecllipse ( eclipse is free)
Install Java:
On windows:
Install from here:
On Linux:
Use the commands in terminal:
- sudo apt-get install openjdk-7-jdk
Install Eclipse:
On windows download eclipse for developers from here: https://www.eclipse.org/downloads/ and install
On linux use these commands:
First download eclipse for developers from here: https://www.eclipse.org/downloads/?osType=linux
Then give these commands from the folder where you have download ecllipse:
- sudo mv eclipse-java-luna-SR2-linux-gtk-x86_64.tar.gz /opt/
- cd /opt
- sudo tar -xvf eclipse-java-luna-SR2-linux-gtk-x86_64.tar.gz
- cd /usr/share/applications/
- sudo nano eclipse.desktop
In this file (which is open in terminal after nano command) write this code and save using ctrl+o and exit using ctrl+x.
- Name=Eclipse
- Type=Application
- Exec=/opt/eclipse/eclipse
- Terminal=false
- Icon=/opt/eclipse/icon.xpm
- Comment=Integrated Development Environment
- NoDisplay=false
- Categories=Development;IDE;
- Name[en]=eclipse.desktop
- X-Desktop-File-Install-Version=0.22
Now write these commands:
- sudo desktop-file-install /usr/share/applications/eclipse.desktop
- sudo ln -s /opt/eclipse/eclipse /usr/local/bin/