Posted By:
10 Feb, 2014 9:52 am PST

1)Step-by-step instruction to write a basic java code?

Step1:- First double click on eclipse IDE (Integrated development environment) and then you
            will enter to eclipse page. 
Step2:-Create a project click on file in that click on new and then click select project.
Step3:-Now we want to create a java project so select java project and click next. And then              we need to give the project name as FirstJavaProject and click next and then click on
Step4:-Then in eclipse IDE on the left side we created a FirstJavaProject in that we have
           source folder where we well store all java programs.
Step5:-Now we need to create a package for that right click on the source click on new in that
           package and create a package name as javacode.example and click on finish.
Step6:- Now we need to create a small java program click on a package(javacode.example)               in that click on new in that select class .
Step7:-Now create a java class in that give class name as MyFirstClass and the class name
           should be in capital letters and subsequent words will also have to be in capital
          letters and there should be no space between these particular words.
Step8:-Then click on public static void main(String[] args) and then click on finish.

Here is the Example:-

package javacode.example;
public class MyFirstClass
Public static void main(String[] args)
//My first statement
System.out.println (“Hello World”); // This is the syntax to print the output

Step9:-Then you need to save this program and then you need to compile and run this
Step10:-Then right click any where on the screen and then click on java Application.
Step11:-Now you can see the output Hello World has been printed on the output screen.

//If you are using just a windows pc with JDK installed in your system, then you just need command prompt (DOS) to write, compile and run your program.

//First open command prompt (DOS) by clicking on run and typing "cmd", click enter or run to start DOS.

//Before starting program, you must have to set enviromental veriable to run javac from any folder.

//To set inviromental veriable for java, follow these steps!

/*Right click on my computer->click on advance system setting->in avance bar, click on inveromental veriables->choose path and click edit-> give a semi colon ';' and paste the folder address of javac ie: "C:\Program Files\Java\jdk1.7.0_07\bin". click ok->ok->and exit. Thats all*/

//Now your DOS is open, goto as specific folder to save your files.

//type edit, it will open an text editor.

//Type the following codes

import java.lang.*;
class hello
public static void main(String args[])
System.out.println("Hey! Buddy");


//Save and close the file.

//Type javac to compile the program.

// If no error occurd then type java MyFirstProgram , the window will show you the message "Hey! Buddy"


Was it useful?  

Please login to reply to this problem.