mercredi 7 janvier 2015

maven how to include dependencies correctly

I was trying to figuring out how to use maven but I didn't get it.


First I tried sqlite 3.8.7 from :



http://ift.tt/1xR8htX



I can compile well but when I try to execute maven doesn't find sqlite jar file, so I try to use :



mvn install:install-file



but It didn't work too, so I just used -cp and I have fixed.


Second I try to use jfreechart from :



http://ift.tt/1xR8htY



I did same steps below for jfreechart but this time it gives me NoClassDefFoundError.


Both of them works when I compile manually but with maven it's not. What I am missing about it ? If I always add manually like sqlite why should use maven anyway ?


Notes : I compile as :



mvn -compile



and I'm packaging as :



mvn -package



and finally I try to execute as :



java -cp target/porject.jar org.path.App



Edit :


This is for jfreechart app(pom.xml) I add dependency tags from mvnrepository.com



<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/VE5zRx">
<modelVersion>4.0.0</modelVersion>

<groupId>org.project</groupId>
<artifactId>ChartTest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>ChartTest</name>
<url>http://ift.tt/19pvvEY;

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version>
</dependency>
</dependencies>
</project>


Thanks in Advance


Aucun commentaire:

Enregistrer un commentaire