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





> 
> 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





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