7

I have created a runnable jar which i included in my project(Maven Project). But when i tried doing mvn clean package. My build gets failed It gives me an error in one of my class imports stating that the package does not exist(which is present in jar).

What i tried:

  1. Tried adding the jat in Web App Libraries.
  2. Adding the jar as external jar.
  3. Adding it in lib folder.

Error Message:

 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project interplan: Compilation failure: Compilation failure:
[ERROR] ..\..\..\MyVehicles.java:[11,40] error: package com.vehicles.parts.manager does not exist

Please guide. Thanks in advance.

sTg
  • 4,313
  • 16
  • 68
  • 115
  • Show the error message and pom file – Jens Jul 05 '16 at 08:30
  • Jens : Its not included in pom file. I have created an external jar by self and want to add. Please understand before voting to close. Its a maven based project. I want this jar to be added externally. – sTg Jul 05 '16 at 08:31
  • This post will help .http://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-in-maven-project – Prabhat Jul 05 '16 at 08:32
  • 2
    Then Google bevor asking: http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them – Jens Jul 05 '16 at 08:33
  • Please check how to include 3rd party jars in a maven project. You need to use the scope in pom.xml. – aksappy Jul 05 '16 at 08:33
  • Could you tell us the name of your external jar? – Sanjeev Saha Jul 05 '16 at 08:43

1 Answers1

14

You need to install your external jar in local repository in following way:

mvn install:install-file -Dfile=c:\kaptcha-{version}.jar -DgroupId=com.google.code -DartifactId=kaptcha -Dversion={version} -Dpackaging=jar

and add the following dependency in pom:

<dependency>
      <groupId>com.google.code</groupId>
      <artifactId>kaptcha</artifactId>
      <version>2.3</version>
 </dependency>

Please replace the values of your external jar for c:\kaptcha-{version}.jar.

Build again and tell me the result.

You may also look at http://www.mkyong.com/maven/how-to-include-library-manully-into-maven-local-repository/

Sanjeev Saha
  • 2,632
  • 1
  • 12
  • 19