1: Java Development on Netbeans Platform

Since Netbeans has released it’s Version 12 it is a strong tool. And therefore I will try to show what is possible with it.

We are starting with opening Netbeans IDE after install on our Mac Computer. As prerequisites I was downloading and installing:

After installing Netbeans and Java we start the Netbeans IDE and open the Netbeans Preferences Menu. In the Tab Java we set the variables modifier to public. That makes it less complex later to work with our windows.

With this install you can write, test and deploy Desktop and Command line Software for all platforms which are supporting Java platform. So the supported platforms will be Windows, MacOS, Linux, Solaris, AIX, Rtos, AutoLinux and many more.

Note: To be able to support Raspberry Pi Platform you need to use OpenJDK 8 or 11. You can even develop on Java 8 or 11 and later run on Java 15 or higher (my tests with Java 17 showed me that 99% of the applications do not need any modification) So if you want to develop for Raspberry PI and all Desktop Platforms you should not install Java 15 Platform but Java 11 Platform. But don’t be in panic: you can choose the platform Netbeans shall use for the project within Netbeans Project Menu.

After starting Netbeans I start a Java with Ant Project, Java Application like you can see on the Picture below.


Clicking Next it shows up a Window where I can set Project name, location and Folder and, I recommend this, let’s you create a Main Class.
One click on Finish shows the generated Program skeleton in the Netbeans IDE.

First I want to generate a Window with some functionality. Here it shall be a Window with a Button and when clicking the Button it shall change the button Title. Let’s test. In my Package Javaapplication4 I am doing above a right click and it opens a Menu:

I choose New and then Frame Form. A Window is opened where I can set the Name, the location and the Package. I will call the name WindowOne
Clicking on Finish shows me the Designer with the empty Window.

In this Window I place a Button and a Label:

On the right side is a Button named properties. Pressing on it Netbeans opens the Properties Editor. So first I select the Button and press then on properties. Here we have three Tabs: Properties, Events, Code. In the Properties Tab I am changing the Text to “Press” and in the Code Tab I change the variable name to mybutton. Then I select the Label and change its name in the code section to my label.

Now I am double clicking on the Button in the Designer and the Netbeans Designer automatically generates the Action event ActionPerformed and I am in the Code Editor in the Button Action:

In the Action Event Method I am doing this command: mylabel.setText(“GootOne”);

Now I am starting the Java Program and waiting for the result: Nothing happened!!!

Now we open the JavaApplication4.Java File which was generated in the beginning. We need to call the Java Page we just generated:

Like you can see: the public static void main Method has no commands. That I should change for our project. I have to tell the Java Programm to open the generated window. That I am doing with this simple code: WindowOne.main(null);

While the WindowOne Code has an own main method I can call the Page with it’s own main method. While I have no args to send to the Window I am sending (null) while args can not be empty but it can be null.

Now I sm starting my Program with the green arrow in the IDE:


and after pressing the button it looks:

As a result we can say, we can generate now Java programs with it. But can we run it outside the IDE? Click on Clean and Build in the Netbeans IDE and have a look on the Output of this process. It shows you even the command for the terminal you can use. While I was building on my System with JDK11 it shows me the right command to run the program with our IDE:


So let’s try it and open a terminal:

and start now the Program:

On every machine where is the JDK 15 or above installed (or 11 and above if you selected Java JDK11) you can run this program. Means: deployment is only deploying the .jar File the IDE generated. Have fun!

5 Likes

Thank you. This looks easy to follow!

Thanks to @MarkusWinter I started to look more for the quality of the Tutorials while it should be better to understand for beginners. So I try to do my best.

3 Likes

Following on from the INN conversation and this EXCELLENT starter tutorial I have moved learning along one step (for me) by going through this Apache Netbeans online tutorial which expands on Thorsten’s information above.
it uses the same ANT project and the SWING GUI, which I am amazed at the ease of use and functionality.

https://netbeans.apache.org/kb/docs/java/quickstart-gui.html

it does not have some of the great details that Thorsten has placed, such as the info about Pi compatibility, which is one of the targets for me, but it does show some great features in the GUI editor.

looking like this is to be my xojo replacement if I can get my serial port code working as I want it to.

Java to the rescue!!! thanks to Thorsten for his constant evangelism of Java.

I got all hardware running. Let me know about I will see and possibly write a driver in c++

All my Apps for PIC/Mac/Pi/Win/Linux use the standard SERIAL port in various client projects, all have my embedded PIC hardware, with some aspect (production, updating, long term communication, data retrieval) of SERIAL port communication.

what I must get in Java is PC OS serial port discovery, connect, disconnect, send and receive, which is super easy in xojo, and why I eventually used it in my projects.
I do not use anything other than 8N1 and never use RTS DTS or other lines, just RX/TX.

that will be my initial focus and the result will determine if I stay in Java land or not.

USB is not an option 99% of the time due to cost (very high count products that use the serial mainly for production and occasional field tests, 50 cent more hardware cost will not be accepted at the bean counter end of things.

All the guys I deal with in engineering still love a serial port!

worst case I could run a xojo console and get the data to the Java from that somehow, but not my preferred option.

I really want to remove xojo completely from all my system if at all possible.

https://fazecast.github.io/jSerialComm/

Would be my first stop in this case

If not specify your needs deeper. Have fun

ok, that looks like a great start, good link.