Get familiar with NetBeans Java IDE
TipsMake.com - In the following article, we will introduce you the most basic features of NetBeans IDE through a small test, which is to create "Hello World" Java application . And when finished, you will know the general knowledge and process when programming applications in the IDE.
1. Initialize Project:
First, start NetBeans IDE . From within the IDE, select File> New Project ( Ctrl + Shift + N shortcut) as shown below:
The New Project window displays, select Java> Java Application . Then click Next :
In the Name and Location section, enter the following information:
- Project Name: HelloWorldApp
- Do not select Use Dedicated Folder for Storing Libraries
- Create Main Class: helloworldapp.HelloWorldApp
- Check the Set as Main Project box
Click Finish and the Project will be opened in the IDE, we will see the following components:
Projects window: with the tree view mode of the project components, such as: source files, libraries .
- The Source Editor window with the HelloWorldApp file is open.
- Navigator window: is used to move between elements within the open class.
- The Tasks window: lists all the errors that occurred during compile and related components, marked with XXX and TODO .
2. Merge Code into Generated Source File:
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!");
}
}
3. Compile and run the program:
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.
4. Building and deploying applications:
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:
- Delete all files that have been compiled and previously built.
- Recompile the application and create a * .JAR file containing the compiled files.
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!
You should read it
- Which career Java programming options are waiting for you?
- eQuiz - Multiple choice quiz about JAVA
- Download and install Java on the computer
- Basic Java exercises, with sample decoding
- How to Install the JDK (Java Development Kit) on a Mac
- How to install Apache Netbean on Windows 10
- What is JAVA file? How to open, edit and convert JAVA files
- How to Set Up a Java Programming Environment
May be interested
- How to install Java on a Raspberry Pithere are two different java implementations, oracle java and openjdk. this tutorial explains how to install java (openjdk) on a raspberry pi with the latest raspbian operating system running on it.
- How to fix the error does not install Javamore and more applications and websites require java installation before use. unfortunately, sometimes you can't install java or install it, but it doesn't work. the article will provide ways to fix errors that do not install java on your computer.
- How to Tune a Java Virtual Machine (JVM)the java virtual machine (jvm) runs your java programs. sometimes the default configuration that the jvm comes with may not be the most efficient for your program.
- How to Run C/C++ Program in Netbeans on Windowsthis tutorial will take you through the process of running a c/c++ program with the netbeans ide (integrated development environment) using screenshots as tools for understanding and clarity. this article is written for use with windows,...
- What is the difference between Go and Java?is golang better than java? is golang harder than java? can golang replace java? this comparison will give you the answer.
- How to Fix Javajava is a computing platform that allows you to play games and view videos on your computer. you can tell that your computer is having problems with java if you see java errors appear when you try to run a program or visit a website that...
- How to Compile a Java Programthis wikihow teaches you how to turn your java source code into an executable app using a local and online compiler. if you're using a computer, the most common way to compile java code is using java software development kit (java sdk)...
- Oracle wants to turn Java EE into fully open sourcethis week, oracle announced plans to move java ee project management to an open source platform, like apache or eclipse.
- Write and run Java code on the computer for the first timeafter you've installed java and set up a path on your computer, you need to know how to run a simple java code on your computer. in this article, we will try to write the first java program, as well as the commands to run this program in cmd.
- Download Java Runtime Environment 8-build-251java runtime environment (jre) is a software class that provides the services needed to execute java applications. it is an essential component of the java development kit (jdk) and contains all the tools needed to run various java-based software programs.