Hi, I have a project using GeoTools to show raster maps; and when I  
run the project in my IDE (Netbeans) I don“t have none problem, but  
when I try to run the jar, it appears several problems.

When I run the jar, it shows the JMap but empty, without the raster map.

This is my code:

https://github.com/viescam/tutorialPruebaMapa

private void displayLayers(File rasterFile) throws Exception {
         AbstractGridFormat format = GridFormatFinder.findFormat( rasterFile );
         reader = format.getReader(rasterFile);

         //Style rasterStyle = createGreyscaleStyle(1);
         Style testStyle = testTwoColorGradient();

         final MapContent map = new MapContent();

         Layer rasterLayer = new GridReaderLayer(reader, testStyle);
         map.addLayer(rasterLayer);

         frame = new JMapFrame(map);
         frame.setSize(800, 600);
         frame.enableStatusBar(true);
         frame.enableToolBar(true);

         frame.setVisible(true);
}

private Style testTwoColorGradient() {
         ColorMapBuilder cm = new ColorMapBuilder();
         cm.entry().quantity(15.02778).colorHex("#008000");
         cm.entry().quantity(100.0000).colorHex("#663333");
         Style style = cm.buildStyle();
         return style;
  }

And my POM.xml is:

<?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/maven-v4_0_0.xsd";>
   <modelVersion>4.0.0</modelVersion>
   <groupId>dihma.upv</groupId>
   <artifactId>tutorialPruebaMapa</artifactId>
   <packaging>jar</packaging>
   <version>1.0</version>
   <name>Tutorial Prueba Mapas</name>
   <url>http://geotools.org</url>

   <properties>
       <geotools.version>15.1</geotools.version>
   </properties>

   <build>
       <plugins>
           <plugin>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                   <encoding>UTF-8</encoding>
                   <target>1.8</target>
                   <source>1.8</source>
               </configuration>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-shade-plugin</artifactId>
               <version>1.3.1</version>
               <executions>
                   <execution>
                       <phase>package</phase>
                       <goals>
                           <goal>shade</goal>
                       </goals>
                       <configuration>
                           <transformers>
                               <!-- This bit sets the main class for  
the executable jar as you otherwise -->
                               <!-- would with the assembly plugin      
                                   -->
                               <transformer  
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                   <manifestEntries>
                                       <Main-Class>mapa.ImageLab</Main-Class>
                                   </manifestEntries>
                               </transformer>
                               <!-- This bit merges the various  
GeoTools META-INF/services files         -->
                               <transformer  
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                           </transformers>
                       </configuration>
                   </execution>
               </executions>
           </plugin>
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-assembly-plugin</artifactId>
             <configuration>
                 <descriptorRefs>
                     <descriptorRef>jar-with-dependencies</descriptorRef>
                 </descriptorRefs>
                 <archive>
                     <manifest>
                         <mainClass>mapa.ImageLab</mainClass>
                          
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                          
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                     </manifest>
                     <manifestEntries>
                         <Specification-Vendor>Sun Microsystems,  
Inc.</Specification-Vendor>
                         <Implementation-Vendor>Sun Microsystems,  
Inc.</Implementation-Vendor>
                     </manifestEntries>
                 </archive>
             </configuration>
             <executions>
                 <execution>
                     <id>create-my-bundle</id>
                     <phase>package</phase>
                     <goals>
                         <goal>single</goal>
                     </goals>
                 </execution>
             </executions>
         </plugin>
       </plugins>
   </build>
   <dependencies>
        <dependency>
           <groupId>org.geotools</groupId>
           <artifactId>gt-epsg-hsql</artifactId>
           <version>${geotools.version}</version>
       </dependency>
       <dependency>
           <groupId>org.geotools</groupId>
           <artifactId>gt-arcgrid</artifactId>
           <version>${geotools.version}</version>
       </dependency>
       <dependency>
           <groupId>org.geotools</groupId>
           <artifactId>gt-swing</artifactId>
           <version>${geotools.version}</version>
       </dependency>
          <dependency>
             <groupId>org.geotools</groupId>
             <artifactId>gt-brewer</artifactId>
             <version>${geotools.version}</version>
       </dependency>
       <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <version>4.5</version>
           <scope>test</scope>
       </dependency>
   </dependencies>
   <repositories>
         <repository>
             <id>maven2-repository.dev.java.net</id>
             <name>Java.net repository</name>
             <url>http://download.java.net/maven/2</url>
         </repository>
         <repository>
             <id>osgeo</id>
             <name>Open Source Geospatial Foundation Repository</name>
             <url>http://download.osgeo.org/webdav/geotools/</url>
         </repository>
     </repositories>
</project>




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to