You do not need to run NetBeans to program Java on the Raspberry Pi. You do not even need an IDE, though that can be helpful.
To run a java program all you need is a Java runtime. The official name from Oracle (the owner's of Java) is the Java Runtime Environment (JRE). This is a collection of libraries plus the application "java" which runs a compiled java program.
To program in Java you need some sort of text editor. An IDE includes this and sometimes will let you switch to your favorite editor. Then you will compile your program with the "javac" application.
There are different runtimes and libraries out there, so you will have to check how to download your favorite to your Raspberry Pi. The last time I checked, Java was included in the Raspian I downloaded for my Pi.
If you want to access the gpio pins of your Pi, you'll need a library that allows you to do this. The two most commons ones are Pi4J and Device I/O. Instructions for downloading them are at https://dzone.com/refcardz/iot-applications-with-java-and-raspberry-pi.
There is also a version of Java designed for embedded computers. Oracle's version is called "Java SE Embedded" and this page, http://www.oracle.com/technetwork/articles/java/raspberrypi-1704896.html, describes it, but it's outdated.