How can I create a war file of my project in NetBeans?
Netbeans will create the Ant script for you, it uses Ant to build anyway. But if you want to get the war file, just build your project. The .war file will be located in /yournetbeanshomedirectory/yourproject/dist/yourwar.war
You can check out the ant build script it uses by looking at the build.xml file in your project directory. Might help you feel a little more comfortable using ant to do builds.
Just check in you projects properties >build ->packaging WAR file compress.
This worked for me:
1.Right click pom.xml
2.Run Maven > Goals
3.Edit maven goals
Results: war build in /target folder
Packaging webapp
Assembling webapp [WeatherDashboard] in [C:\Users\julian.mojico\Documents\NetBeansProjects\WeatherDashboard\target\WeatherDashboard-1.0-SNAPSHOT]
Processing war project
Webapp assembled in [672 msecs]
Building war: C:\Users\julian.mojico\Documents\NetBeansProjects\WeatherDashboard\target\WeatherDashboard-1.0-SNAPSHOT.war
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 1:41.633s
Finished at: Tue Sep 05 09:41:27 ART 2017
Final Memory: 18M/97M
------------------------------------------------------------------------
It's possible that you already have a war file and don't know it - netbeans does most of the work for you and I believe it creates a distributable war file by default. If you created a web project and successfully built it, it will be in the "dist" directory off your project root.
It is in the dist folder inside of the project, but only if "Compress WAR File" in the project settings dialog ( build / packaging) ist checked. Before I checked this checkbox there was no dist folder.
As DPA says, the easiest way to generate a war file of your project is through the IDE. Open the Files tab from your left hand panel, right click on the build.xml file and tell it what type of ant target you want to run.