At the top, we have selected the Create Main Class checkbox when creating Project , so the IDE will create the main class. You can assign " Hello World! " To the main code section by replacing the line:
// TODO code application logic here
by code:
System.out.println ("Hello World!");
Select File> Save to save the changes. Our result file in this step will look like this:
/ *
* To change this template, choose Tools | Templates
* và mở tập tin mẫu trong phần mềm.
* /
package helloworldapp;
/ **
*
* @author
* /
public class HelloWorldApp {
/ **
* @param args the arguments line command
* /
public static void main (String [] args) {
System.out.println ("Hello World!");
}
}
Because the IDE's Compile feature is in the Save section, so we will not have to compile the previous project to be able to run inside the IDE. When saving a Java source file, the IDE automatically compiles it. Note that the Save Compile function can be turned off in the Project Properties by right-clicking on the project and selecting Properties . In this Properties window, select the Compiling tab, with the Compile on Save checkbox at the top right. This Project Properties can also adjust settings for: project libraries, packaging, building, running .
To run the program, select Run> Run Main Project or press F6:
When the system displays the message as above it means that the compilation process was successful
If an error occurs, they will be marked with a red arrow symbol on the left and right-aligned at the Source Editor section . The markings on the left will correspond to the lines of the code containing the error, and the right error symbol will indicate all the files with errors, including unseen errors. Click the error icon to move to the line containing the code.
After writing the source code, checking it, we can use the Clean and Build feature to build the program. Using this Clean and Build command, the IDE will run the necessary code to perform the following tasks:
To build the program, select Run> Clean and Build Main Project or press the shortcut Shift + F11 . We can check the built files by opening the Files window and expanding the HelloWorldApp section (the name of the project). File bytecode HelloWorldApp.class after compilation is inside the build / classes / helloworldapp section . Package the * .JAR file containing the HelloWorldApp.class file inside the dist.
Very simple and easy, wish you success!