Java development tools and your First java program

Java development tools

But if you are new to java it is better to use Text editor like

But in this way you have to compile manually. You need command prompt to compile and run the programs. Let’s see how to save, compile and run java programs.

Your first java program

Class name is ‘Hello’

You can type this in your text editor.

When you are saving, there is a genuine method.

You have to save your program with ‘.java’ extension and the file name should be the class name which contain the main method.

In this program,

  • Hello – class name
  • Public – access modifier
  • Static – can be accessed without requiring an instantiation of the class to which it belongs
  • Void – not return anything
  • Main – main method
  • String – string data type
  • Args[ ] = array
  • System.out.println(“ ”) – this is for display somthing in java

Saving the file.
  1. Save the file as in known folder.
  2. Just think I saved this file in Desktop in the folder named Ravi.
  3. Then go to the command prompt.
  4. Windows 7 – start-> run-> type cmd and enter.
  5. Windows 8 – press windows button-> type cmd-> select command prompt.
  6. Now you have to select where your file has been saved.
  7. You can change the directory by typing cd<space>folder name or partition.
Ex: I created a folder in desktop named Ravi, to access this folder in cmd.

So you have to change directory to desktop first and then change the directory to Ravi folder.

cd desktop
and then,
cd Ravi

Now you can access the file.

You have to compile the file before run.

Compiling command is ‘javac’

Type javac

Then you can run the file.

Running command is java

Type java Hello

Look at this image to understand.

Java development tools and your First java program Java development tools and your First java program Reviewed by Ravi Yasas on 10:50 PM Rating: 5

No comments:

Powered by Blogger.