(java@oneshot) logo  logo  logo  logo

JAVA TUTORIAL

About java :

Java is a high-level programming language and platform, developed by Sun Microsystems. java created a new sense of the interactive possibilities of the Web. Both of the major Web browsers include a Java virtual machine. Java runs on various platforms, such as Windows, Mac OS, and the various versions of UNIX.

Almost all major operating system developers (IBM, Microsoft, and others) have added Java compilers as part of their product offerings.

Advantages of java :

Java is easy to learn.

   -Java was designed to be easy to use and is therefore easy to write, compile, debug, and learn than other programming languages.

Java is object-oriented.

   -This allows you to create modular programs and reusable code.

Java is platform-independent

where it is needed :

There are many places where Java is used in real world, starting from commercial e-commerce website to android apps, from scientific application to financial applications like electronic trading systems, from games like Minecraft to desktop applications like Eclipse, Netbeans and IntelliJ, from open source library to J2ME apps etc.

How to write a basic java program :

class BasicProgram {
    public static void main(String[] args) {
      System.out.println("Hello World!"); // Displays Hello World!
    }
}

Type above lines of code in notepad. You can save the above program as BasicProgram.java(Be careful about uppercase and lowercase, because java is a case-sensitive language).

How to compile java program

open command prompt (You can do this from the Start menu by choosing Run... and then entering cmd)

To compile your source file, change your current directory to the directory where your file is located.

For example, if your source directory is java on the C drive, type the following command at the prompt and press Enter:

cmd>cd C:\java

Now the prompt should change to C:\java>

Now you are ready to compile. At the prompt, type the following command and press Enter.

cmd>javac BasicProgram.java

If your program doesn't have any errors, you can run your program.

How to run java program

enter the following command at the prompt:

cmd>java -cp . BasicProgram

You should see the following on your screen:

cmd>C:\java>java -cp . BasicProgram

cmd>Hello World!

now you got know how to write, compile and execute a java program

You can also learn:

Language

Operators

Statement Control

Class Defination

Development

Reflection

Collections

File

Generics