Creating & Running a Java Program
- BlueJ is an IDE for Java. It provides an editor and access to the standard Java compiler and runtime system. The two methods of creating and running Java programs are: general method and using BlueJ.
- To create a Java program using general method, start a text editor such as Notepad and type the Java source code. Click on Start menu. Select Run and type CMD.exe. Now, change directory to bin folder using CD command. Compile the program using Java compiler javac.If compilation is successful, it will create a dot class file for every class given in the source code.
- To run a program on command prompt, type java followed by the name of the initial class.
- BlueJ is specifically designed to learn and teach object-oriented approach. After running BlueJ, the main window will open.
- To create a Java program using BlueJ, select Project menu and click on New Project. Enter project name and click on Create.Create a new class by clicking on New Class. Type file name in the dialog box and then click on Ok. Class icon will appear in the window. Double click on it to open the class editor.Delete the default code and write the code in this editor. Compile the program usingCompile button and click on it. Now, right click on the compiled icon of class and select the main method.
- The main method executes main method of class. Click on OK button. The output of the code appears.
Comments written in the beginning of a program are calledMarks:1
Explanation:It is few lines of code or statements in the beginning of a program that summarises the purpose of the program and increases program understanding ability.
In Java, statements are terminated with aMarks:1
Explanation:Semicolon (;) is used to terminate statements in Java. The simplest statement is a null statement or an empty statement.
The operator that returns a reference to a new instance of a class isMarks:1
Explanation:The new operator returns a reference to a new instance of a class. All objects are created with the new operator.
An application program consisting of different development tools needed for developing an application, is calledMarks:1
Integrated Development Environment.
It is a software application that provides facilities to computer programmers for software development.
A special kind of Java program that a browser enabled with Java technology can download from the internet and run, isMarks:1
Explanation:An applet is typically embedded inside a web-page and runs in the context of the browser.