Home Java Learn Java - Learn Java Quickly
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Learn Java - Learn Java Quickly

Advertisement
Java is an object oriented programming language developed by Sun Microsystems.

Learn Java - Learn Java Quickly

     

Java is an object oriented programming language developed by Sun Microsystems. This is freely available to public for all purposes from personal website development to big enterprises. It looks lot like C and C++ but has various extra-developed features that make it safer, easier and more useful than other object oriented languages. It is now most demanded programming skill used for developing various web-based application in e-commerce and universities.

The most important feature of Java is that it can run on different types of computer without any modification. This feature is popularly known as ?Write once, run anywhere?. Again, it is used widely with Server Side web programming, where the program runs on the web server and the user can see the page using any web browser.  Also programs developed by using Java technology can be sold without paying or consulting to the Sun Microsystems.

Java Virtual Machine (JVM)

It is the principal component of Java architecture that provides the cross platform functionality and security to Java. This is a software process that converts the compiled Java byte code to machine code. Byte code is an intermediary language between Java source and the host system.

Most programming language like C and Pascal translate the source code into machine code for one specific type of machine as the machine language vary from system to system. So most complier produce code for a particular system but Java compiler produce code for a virtual machine. The translation is done in two steps. First the programs written in Java or the source code translated by Java compiler into byte code and after that the JVM converts the byte code into machine code for the computer one wants to run.

So the programs files written in Java are stored in .java files and the .java files are compiled by the Java compiler into byte code that are stored in .class file. The JVM later convert it into machine code. In fact the byte code format is same on all platforms as it runs in the same JVM and it is totally independent from the operating system and CPU architecture. JVM is a part of Java Run Time Environment that is required by every operating system requires a different JRE. JRE consists of a number of classes based on Java API and JVM, and without JRE, it is impossible to run Java. So its portability really made it possible in developing write once and run anywhere software.

In the following figure you can see the function of JVM

How to write your First Java program

Ok, now you know the basics of Java programming and have downloaded the Java Development Kit (JDK), then its time to write your first Java program.

Create a source code program in any of the text editor available like jEdit, Notepad, TextPad etc. Java program is a class with a main method in it. The main method is the starting point for every Java application. So first define the class name and lets take it as FirstProgram and write it in the text editor like below

public class FirstProgram

{

   public static void main(String[] args)

   {

  System.out.println("Hey! you are going to compile and run your first Java program");

   }

}

Here System.out.println is the incantation that one uses to get codes sent to the console. Now save the file with same name as the public class just adding the extension ?.java? . Here for example FirstProgram.java. If you use a different name other than the existing class name then you will face while compiling.

After completing the above, open a doss command window and type cd to the directory in which your source file exists. Type the following code to compile the file. This should be like this:

javac FirstProgram.java

If you compile it successfully, then you can find a class file in your directory with the same name, which is the bytecode form of Java program. Now type FirstProgram.java  to run the program.

The JVM now will run the bytecode in the FirstProgram.class file. Now you will see the output on your screen as:

Hey! you are going to compile and run your first Java program

Congratulation! Now you have successfully developed your first Java program. 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 11, 2008

Related Tutorials

Ask Questions?    Discuss: Learn Java - Learn Java Quickly   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
irfan sagir
April 5, 2011
jave programming

I want to learn jave programming to increase my skills.
k.Gangadhar
May 26, 2011
java

java is very well
lokesh reddy
May 28, 2011
how to develope programe

dear sir, iam interested to settle as a java programer thats why i am doing java in institute. i just completed my core java. i was interested how the programs are evelope on core java.can you pls help me how the programers develope the programs on core java. thank q, your's faithfully , LOKESH REDDY.
Degapudi siva kumar reddy
June 13, 2011
java

I am learning java quickly use roseindia.net
Rohit Raj Sinha
June 21, 2011
core java

i want to learn core java.
mohan
July 8, 2011
java

i want to learn java quickly
ina
July 10, 2011
java

this is very support of java beginner learns of the world
mohammad nazmul wahid
August 19, 2011
java

i would like to learn java programming within a short time.
geetu
August 27, 2011
java

thanks.i like you teaching way
prabu
September 13, 2011
this website

It's very useful and good understanding for students
sindhu
February 9, 2013
I want to subscribe

please send me the information like OOP concepts, constructor, method, etc., about java on my mail id.
sdfsdadsf
December 9, 2011
java programming language

please suggest me a way to learn how to write a java coding.......
Ashish Jain
December 13, 2011
Basics of Java

Good
armand
January 27, 2012
Java

Can anyone help me to do a program to park some cars in a parking. i have to calculate the time a car rest in parking, to insert a car in parking if there is free place to park and to see if a car is parked....Thanks
sonu upadhyay
January 30, 2012
java program

i want to learn java.
satyam gupta
June 7, 2012
core java

i want core java classes as soon as possibe.
Gowri
July 11, 2012
How to learn java

Hi , I want to be expert in java, but i was not in good in C,C++, language but interested in java Plz help me ,make me to understand the java anguage.
alli
July 12, 2012


Good morning pls can i get a step to step method on how to learn java language
Prasoon Tiwari
July 25, 2012
java beginners

Sir i need to learn java from begining please send me some basic usefull concept in java with their example so that i can learn java by using this website because for beginners there is some problems to understand a big program firstly.there should be step by step explanation of each word used in this language. Thanking you.
Timothy samuel
December 9, 2012
learn java

hello i want to learn how to right java in one week thank you..............
abhu
December 2, 2012
pls find bugs here

package Librarymgmt; import java.io.*; import java.util.*; public class Main { static Integer Id,CNo; static String Name,Author,BookName; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static ArrayList<Student> al = new ArrayList<Student>(); static HashMap<String, String> hm = new HashMap<String, String>(); public static void main(String[]args) throws IOException{ hm.put("Abhi", "Java for NON IT"); hm.put("Arlur", "Java for Begginers"); hm.put("Madhu", "Java for proffessionals"); hm.put("girish", "Java for Lap"); hm.put("bharath", "Java for TCS HYD"); while(true){ int home; //System.out.println(home); System.out.println("1.Add student detail"+"/n 2.view student detail"+ "/n 3.view books"+ "/n 4. search using author name"+"/n 5.Issue book"+ "/n 6.return book"+ "/n 7.Exit" ); System.out.println("plese enter your choice"); home=Integer.parseInt(br.readLine()); switch(home){ case 1: addStd(); break; case 2: viewStd(); break; case 3: viewBooks(); break; case 4: searchBook(); break; case 5: issueBook(); break; case 6: returnBook(); break; case 7:System.exit(0); default: return; } } } static void addStd() throws IOException { System.out.println("Enter your name"); Name=br.readLine(); System.out.println("Enter your ID"); Id=Integer.parseInt(br.readLine()); System.out.println("Enter your card no"); CNo=Integer.parseInt(br.readLine()); Student s=new Student(Name,Id,CNo); al.add(s); } static void viewStd() throws IOException { for (Student s : al) { System.out.println("Student Name: " + s.getName() + "\tCollege Id: " + s.getId() + "\tLibrary Card No.:" + s.getCNo() + "\n"); } } static void viewBooks() throws IOException { Set<Map.Entry<String, String>>u = hm.entrySet(); for (Map.Entry<String, String> ab : u) { Library lib = new Library(ab.getKey(), ab.getValue()); System.out.println(ab.getKey() + " " + ab.getValue()); } } static void searchBook() throws IOException { System.out.println("Enter The Auther Name"); Author = br.readLine(); Set<Map.Entry<String, String>> set= hm.entrySet(); int count=0; for (Map.Entry<String, String> me : set) { Library lib = new Library(me.getKey(), me.getValue()); if (lib.getAuthorName().equalsIgnoreCase(Author)) { System.out.println("Book Found"); count++; break; } } if(count==0) { System.out.println("Book is Not Found"); } } static void issueBook() throws IOException { System.out.println("Enter The Auther Name"); Author = br.readLine(); System.out.println("Enter The Book Name"); Name = br.readLine(); System.out.println(Author); Set<Map.Entry<String, String>> set = hm.entrySet(); int count=0; for (Map.Entry<String, String> me : set) { Library l = new Library(me.getKey(), me.getValue()); if (l.getAuthorName().equalsIgnoreCase(Author)) { System.out.println("Book Issued"); count++; break; } } if(count==0) { System.out.println("Book is Not Found"); } } static void returnBook() throws IOException { System.out.println("Enter The Auther Name"); Author = br.readLine(); System.out.println("Enter The Book Name"); Name = br.readLine(); System.out.println(Author); Set<Map.Entry<String, String>> set = hm.entrySet(); int count=0; for (Map.Entry<String, String> me : set) { Library l = new Library(me.getKey(), me.getValue()); if (l.getAuthorName().equalsIgnoreCase(Author)) { System.out.println("Book returned"); count++; break; }} } }
vani
July 19, 2013
corejava

hi sir, i hav theritical knowledge in java concepts like core java and advanced java like servlets and jsp also.pls suggest me how to how to programs in java.i want some detail explaination of programs on java.
DMCA.com