DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • Deploy Maven Apps to Kubernetes With JKube Kubernetes Maven Plugin
  • Using Python Libraries in Java
  • DGS GraphQL and Spring Boot

Trending

  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • Top Book Picks for Site Reliability Engineers
  • Intro to RAG: Foundations of Retrieval Augmented Generation, Part 1
  • Building Enterprise-Ready Landing Zones: Beyond the Initial Setup
  1. DZone
  2. Coding
  3. Java
  4. Importing a Maven Project in NetBeans

Importing a Maven Project in NetBeans

Learn more about how to import a Maven Project in Netbeans.

By 
Alejandro Duarte user avatar
Alejandro Duarte
DZone Core CORE ·
Nov. 25, 19 · Tutorial
Likes (8)
Comment
Save
Tweet
Share
18.2K Views

Join the DZone community and get the full member experience.

Join For Free

Coffee cup and coffee beans

Learn more about how to import a Maven Project in Netbeans.

This tutorial explains how to import an existing Maven project into Apache NetBeans and how to associate Maven goals to IDE actions. This is useful, for example, when using the Jetty Maven plugin that allows you to quickly deploy and run a Java web application using this popular server.

Maven is a project management tool that goes beyond dependency management. See  Learning Maven Concepts for more.

Download an Existing Maven Project

This tutorial uses a Maven archetype that generates a Java web application with a preconfigured Jetty Maven Plugin in it:

mvn -B archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=LATEST -DgroupId=org.test -DartifactId=webapp -Dversion=1.0-SNAPSHOT


If you prefer, you can generate a ZIP file with this project at https://vaadin.com/start/latest or https://start.vaadin.com. Make sure you select the Plain Java Servlet option before downloading the project.

The project should include a directory with a Maven project in it:

Maven project directory

You need Node.js installed on your computer to compile the example application.

Import the Project

  1. In NetBeans, select File > Open Project….
  2. Select the directory corresponding to the Maven project, and click Open Project to complete the process: Open project

Running Maven Goals

NetBeans has excellent integration with Maven. You can run common commands such as mvn clean or mvn jetty:run without having to leave the IDE.

When you select the project in the Projects view, NetBeans shows common Maven goals inside the Navigator view:

Navigator view

You can execute any of these goals by double-clicking them. For example, you can double-click the jetty run goal to run the web application implemented in the project you imported.

To stop the server, click the stop button in the Output view:

Output view

Binding Maven Goals to IDE Actions

Since using the jetty:run goal could be a frequent task during the development of a Java web application, you might prefer to bind this Maven goal to an IDE action.

Let’s associate the Run project action to the jetty:run Maven goal.

  1. Right-click the project in the Projects view and select Properties.
  2. In the Project Properties window, select Actions in the Categories tree.
  3. Select the Run project option in the Actions list.
  4. Type jetty:run in Execute Goals.
  5. Click OK: ActionsIf you are using Spring Boot, use the spring-boot:run goal.

Now, you can deploy and run the web application by clicking the run icon in the toolbar:

Toolbar

You can repeat the process to bind the jetty:run goal to the Debug project IDE action as well.

If you use the Vaadin project used in the tutorial, you can invoke the web application at http://localhost:8080.

That’s it. Now, you can use NetBeans to develop your Maven application! Happy coding!

Further Reading

My Experiences With Maven in IntelliJ IDEA and NetBeans IDE

[DZone Refcard] Essential NetBeans Platform

Apache Maven NetBeans Web application

Published at DZone with permission of Alejandro Duarte. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • Deploy Maven Apps to Kubernetes With JKube Kubernetes Maven Plugin
  • Using Python Libraries in Java
  • DGS GraphQL and Spring Boot

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!