NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdf-java] Maven dependency problem with slf4j

Also, we hope to have all these maven issues worked out soon in 4.3

On 4/1/2012 11:22 AM, Noah Watkins wrote:
Thanks all,

These suggestions worked just great :)

-Noah

On Mar 30, 2012, at 9:34 AM, Curtis Rueden wrote:

Hi Noah,

In addition to what Brian suggested, one other thing:

B) Alternatively, if you want to build a executable jar or just dump all the 
dependencies into a directory

You can also use "mvn dependency:copy-dependencies" to dump all the 
dependencies into the target/dependency directory, for easy access.

Regards,
Curtis


On Fri, Mar 30, 2012 at 11:17 AM, Brian Schlining<bschlining@xxxxxxxxx>  wrote:





Build works great, but I am trying to resolve dependencies to this installation 
locally with another package, and I am running into problems. I am using one of 
the basic netCDF-Java examples from the netCDF-Java website. This is the 
pom.xml file I am using to compile, while successfully resolves the netCDF-Java 
dependency:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";>

<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<name>test</name>

<dependencies>
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>netcdf</artifactId>
<version>4.3.8-SNAPSHOT</version>
</dependency>
</dependencies>

</project>

However, when I try to run the example program,

$ java -cp target/test-0.1.jar Test

Exception in thread "main" java.lang.NoClassDefFoundError: 
ucar/ma2/InvalidRangeException

And so on. Is there a way to include all of these sub-dependencies 
automatically, given that I already included netcdf?
Yes,

---- THE SHORT ANSWER:

To get a classpath with all the dependencies for your project run:
mvn dependency:build-classpath



---- THE LONG ANSWER

A) You can also just use Maven to run your test program. Here's some examples:

1) Without args
mvn exec:java -Dexec.mainClass="Test"

2) With args
mvn exec:java -Dexec.mainClass="Test" -Dexec.args="foo bar"



3) With runtime dependencies in the CLASSPATH
mvn exec:java -Dexec.mainClass="Test" -Dexec.classpathScope=runtime




B) Alternatively, if you want to build a executable jar or just dump all the 
dependencies into a directory, you should take a look at maven's assembly 
plugin. There's an example assembly descriptor at 
http://code.google.com/p/vcr4j/source/browse/trunk/src/main/assembly/download-bundle.xml


C) Finally, If you just want to see what dependency's are used by your project 
run:
mvn dependency:tree

Cheers

--
Brian Schlining



_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: 
http://www.unidata.ucar.edu/mailing_lists/

_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: 
http://www.unidata.ucar.edu/mailing_lists/



  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: