JAVA is an Object Oriented Programming. It is called Object Oriented mainly JAVA program has a class that created a specific Object. a well written class can be use many time . A class is like template on a model. Which also provide Code and method that help retrieve its Value and Attributes. For Example: A class Name is "Employee" and it creates an object of this class. it has different attributes and values such as First Name, Last Name, and age etc. Java Programming Can be written 3 different kind of form:
JAVA Applets
JAVA Servlets and
JAVA used Both a compiler and interpreter. First, compile the program in to binary code or machine language then interpret the binary code at run time to process the program and given a result or output. So JAVA used both combination of Compiler and interpreter. JAVA uses a Software to compile and run the programs is called JVM (Java Virtual Machine) Founded by Sun Microsystem. Currently, Sun Microsystem release a new version of Netbeans 7.0.1 IDE (Integrated Development Environment). Netbeans and JVM are open source can be downloaded from Sun Microsystem web site.
Now sun microsystem merge in to Oracle here is the link I always visit to download and other related information: www.java.sun.com
Overview of JAVA Applications
JAVA Application is a standalone and run on a client computer. A simple JAVA class can be written on a text editor Notepad and Compile and Run on a Command prompt or DOS Prompt. Also, the smart way we can coding, debugging, compile and Run the JAVA applications on a Netbeans IDE. Here I follow these steps to create, compile and Run a simple Java class program. on a DOS command prompt and Netbeans:
In DOS command and using text editor
First, need to create a folder. For example I create a folder in my C:\ContactInfo
Create a class by opening a notepad and save it into the folder with(.java) file extention. For example: I created a class name Contact and save it in to the ContactInfo folder as C:\ContactInfo\Contact.java. class name and file name always should be same such as I used my class name Contact and the file name Contact.java. I used all string Variables and given a value to each attributes of Contact object such as, First name, last name, Phone Number etc. to retrieve all string values using Main method which is public static void main(string[] args) and System.out.println() statements for the output. Also, using String CONCATENATION OPERATOR adding String variable and string using "+" and JAVA Characters Newline "\n" and Tab"\t" here is the sample of how to create a Java class:
open command prompt to compile this Contact class first need to go to the directory where the Contact.java located here is an image where mine Contact.java located:
compile with Command javac Contact.java after compile the Contact.java, it created another binary file name Contact.class. here is a screenshot showing how I compile the contact class and created a binary .class file in the same folder:
Now the Program ready to Run with java command by interpreting the binary file. with java command no need to give the extenstion only the class name (Contact). Here is a screen shot showing how to run and given an output:
if java and javac command not working in DOS Prompt then need to set up the PATH ENVIRONMENT variable.
Using Netbeans IDE to Compile and Run
The same Java Application can be created, compiled and Run better, efficient and smarter way by using Netbeans IDE. I am showing here using the same Contact.java in Netbeans IDE step by step how to create, compile and run and Java application.
Create Project
Creating a new project in Netbeans, we can choose new project icon from menu bar or from file => new project, here is an image showing how to create a project. I gave my project Name same as before ContactInfo and Program Location C:\ drive and make sure checked on main class and class name I choose Contact here and the click finish button.
it created a project ContactInfo with Contact main class Automatically no need to create a main class. This is another image showing the project. Left side showing how to managing ContactInfo project folders, Contact.java has already created in source default folder:
and here is an image of main class created and showing class name Contact Public Static main method automatic created only need to adding line od code:
2. writing the code
Writing code in netbeans is easier, because it is showing the line numbers, color coded help to find out java different java word and statements. also, it helps to debugging the code very efficiently.
3.Build and run the application
To build and Run the project simply choose build button from menu bar after successfully build the project and class, we can use run button from menu bar. Here is an image showing build, compiled and run the application showing build successful and output on output pan:
4.Managing files and folder
in netbeans IDE dont need to create any folder or class file it just created automatic when it created project. Here is an image showing package of folders on netbeans Ide and folders created on folder's location C:\
and when build the project it compiled and automatically created build folder and class file created inside this folder. this is an image of build folder netbeans created on folder location C:\
References:
textbook JAVA 6 illuminated by Julie Anderson
courseweb:http://www.cob.unt.edu/itds/courses/bcis3630/bcis3630.htm