- #ADD MAVEN TO INTELLIJ JAR PROJECT HOW TO#
- #ADD MAVEN TO INTELLIJ JAR PROJECT INSTALL#
- #ADD MAVEN TO INTELLIJ JAR PROJECT UPDATE#
- #ADD MAVEN TO INTELLIJ JAR PROJECT CODE#
If the existing project contains more than one module, converting such a project into the Maven project becomes quite challenging. You can right-click the generated JAR and select Run to execute the file. IntelliJ IDEA generates the appropriate information in the target folder and an executable JAR in the Project tool window.
#ADD MAVEN TO INTELLIJ JAR PROJECT INSTALL#
In the Maven tool window, in the Lifecycle list, double-click the install command to generate the jar file. In your POM specify the Manifest file information, so you can use Maven to generate an executable jar file. Note that IntelliJ IDEA only compiles sources and doesn't create either JAR file or Manifest file.Ĭreate a Manifest file in the resources directory. You can conclude the following optional steps to create an executable JAR.Ĭlick to build project. We recommend making all your project changes in POM since IntelliJ IDEA considers pom.xml as a single source of truth. The artifactId and version are specified automatically.Įvery time you change the POM, IntelliJ IDEA displays a popup suggesting to import your changes.Īt this point you can further develop your project using Maven.
Open the generated POM and specify a groupId. IntelliJ IDEA also creates a corresponding structure with Lifecycle and Plugins in the Maven tool window.
#ADD MAVEN TO INTELLIJ JAR PROJECT HOW TO#
IntelliJ IDEA adds a default POM to the project and generates the standard Maven layout in Project tool window. This video shows how to add MySQL jar file (mysql-connector) to a Java project using IntelliJ IDEAFix Error No suitable driver found for jdbc. In the dialog that opens, select Maven from the options on the left and click OK.
In the Project tool window, right-click your project and select Add Framework Support. Open an existing project, for example, a Java project. Maven should have generated jar file for each project there.That’s how to create a multi-module Maven project in IntelliJ IDEA.You can open an existing non-Maven project and add a Maven support via IntelliJ IDEA UI. Select the root project, and click button Execute Maven Goal, and double click mvn install from the list, as shown below: Then you should see the Maven’s build success output as follows: Now you can check the target directory in each project. Build a Multi-Module Maven project in IntelliJ IDEATo build the whole multi-module Maven project in IntelliJ IDEA, open Maven view. SwingUtilities.invokeLater(new Runnable() void run() You see, this class also makes use of the CommonUtility class from the SharedLibrary project.ĥ. Static String appName = CommonUtility.getAppName() Īdd(new JLabel("Welcome to " + appName))
#ADD MAVEN TO INTELLIJ JAR PROJECT CODE#
We would end up having the modules declared in the root project like this: įor demo purpose, code a simple Swing program for the desktop app with the following code: package com.mycompany Create the DesktopApp projectSimilar to the ConsoleApp project, create the third Maven module for the DesktopApp project. }You see, this class makes use of the CommonUtility class from the SharedLibrary project.Ĥ. String appName = CommonUtility.getAppName()
#ADD MAVEN TO INTELLIJ JAR PROJECT UPDATE#
Note: You may need to Reload Maven project to update the dependency information.Then code a simple console program like this: package com.mycompany And in order to reference the SharedLibrary project, you should declare the dependency in the pom.xml file of the ConsoleApp project as follows: Create the ConsoleApp projectSimilarly, create the second Maven module for the ConsoleApp project. }The static method getAppName() will be used by both console app and desktop app.ģ. And in this SharedLibrary project’s pom.xml file, it specifies the parent information as below: Īnd code a simple class in this project as follows: package com.mycompany You see, it specifies the packaging type is pom, and adds a module named SharedLibrary. You can notice the pom.xml file of the root project was updated: IntelliJ IDEA will create the SharedLibrary project under CompanyProject. Note that the parent module is CompanyProject: Click Finish. Right-click on the root project, and select New > Module: Then enter the module name as SharedLibrary. Create the SharedLibrary projectNext, we create the first Maven module for the shared library project.
Choose Maven and click Next: Enter project name and specify artifact coordinates information as below: Click Finish. In IntelliJ IDEA’s welcome dialog, click New Project.