0

I have a Maven project in Netbeans.

I have locally a jar which I want to insert to the project.

Through cmd I run the command

C:\Users\Alia-PC>mvn install:install-file-Dfile=C:\opt\glassfish4\glassfish\dom ains\domain1\applications\myproject\files\rrunner_ja r\Ropt-Updated.jar \ -DgroupId=rcaller -DartifactId=RCaller \-Dversion=2.4 -Dpackaging=jar -e

But I receive this error for pom.xml.

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.094 s
[INFO] Finished at: 2016-05-23T14:27:42+03:00
[INFO] Final Memory: 5M/77M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
 in this directory (C:\Users\Alia-PC). Please verify you invoked Maven from the
correct directory. -> [Help 1]
org.apache.maven.lifecycle.MissingProjectException: The goal you specified requi
res a project to execute but there is no POM in this directory (C:\Users\Alia-PC
). Please verify you invoked Maven from the correct directory.
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:84)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProject
Exception

Even if I tried to make a

cd C:\opt\glassfish4\glassfish\domains\domain1\applications\myproject\

can anyone tell me the cause of problem and how to fix it?

bananas
  • 1,176
  • 2
  • 19
  • 39
Emklj
  • 39
  • 10
  • I guess this https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html and this http://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-in-maven-project could help you. – Bilbo Baggins May 23 '16 at 11:40
  • @BilboBaggins thank you. For the second link I had tried the answer http://stackoverflow.com/a/22300875/6326346 but I could set the systemPath right. I can't understand how I could write correct the ${project.basedir}/src/main/resources/yourJar.jar Please could you help me? – Emklj May 23 '16 at 11:43
  • Ummm a guess, you have to try somethign like this from the current directory of project to the path of lib. – Bilbo Baggins May 23 '16 at 11:48
  • sorry, it is not related to your question, but the version of 2.4 is quite old. – jbytecode May 25 '16 at 00:38

1 Answers1

0

It's a two step process:

To Install 3rd party jar in local:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

Making the jar available to your project:

Specify the jar dependency in your pom with the same detail which you have defined while installing it locally and build your project from your project directory.

<dependency>
            <groupId>Specified GroupID</groupId>
            <artifactId>Specified ArtifactID</artifactId>
            <version>Specified Version</version>
  </dependency>

What this error is saying to me is that you are trying to build from a directory other than your project directory where no pom is defined.

Ideal Maven folder structure:

Project
      |
      ---src
           |
           ---main
                 |
                 ---java
                 ---so on
           ---test
                 |
                 ---so on
      ---Pom.xml
Helios
  • 851
  • 2
  • 7
  • 22
  • Thank you for your answer. I have the project in a file which contains a subfile with have the src of the project and another subfolder in the parent folder which has the jar file. The dependecies exist in pom.xml – Emklj May 23 '16 at 12:30
  • I have updated my answer with a ideal project structure. As you can see the pom should be at the root directory. Anyway you need invoke build from the directory where `pom` is residing. – Helios May 23 '16 at 12:41