Using Java Advanced Imaging with Maven

后端 未结 9 2255
执笔经年
执笔经年 2020-12-08 09:30

The JAI setup is quite tedious, involving multiple jars and environment variables. It would aid the project\'s portability quite a lot if I could add it as a regular Maven d

9条回答
  •  温柔的废话
    2020-12-08 09:50

    This worked for me:

    
        org.geotools
        gt-coverage
        2.7.4
    
    
    
        osgeo
        Open Source Geospatial Foundation Repository
        http://download.osgeo.org/webdav/geotools/
    
    

    It seems that gt-coverage depends on jai_imageio, so it installed the appropriate jars for me. I didn't even have to change my code to use this artifact.

    This will get your code working within your IDE. However, if you want an executable jar, then you need to use the Maven Shade plugin. Its use is described here and here. Note the extra lines in the 2nd link because they are necessary. Here's the extra code to go in your pom:

    
        org.apache.maven.plugins
        maven-shade-plugin
        1.3.1
        
            
                package
                
                    shade
                
                
                    
                        
                            
                                com.companyname.packagename.MainClassName
                                Java Advanced Imaging Image I/O Tools
                                1.1
                                Sun Microsystems, Inc.
                                com.sun.media.imageio
                                1.1
                                Sun Microsystems, Inc.
                                com.sun.media.imageio
                            
                        
                        
                    
                
            
        
    
    

    I don't know what all those extra manifest entries are, but they make my executable jar do what it does in the IDE.

提交回复
热议问题