java.lang.NoClassDefFoundError: Could not initialize class javax.media.jai.JAI -
i started first program geotools in using jai- java advanced imaging 1_1_2_01 jdk 1_7. it worked fine until added geotiff jars. found following error
exception in thread "main" java.lang.noclassdeffounderror: not initialize class javax.media.jai.jai @ org.geotools.gce.geotiff.geotiffreader.read(geotiffreader.java:607) @ com.rgb.pixelextractor.extract(pixelextractor.java:55) @ com.rgb.rgbspliter.main(rgbspliter.java:136)
the code below
public void extract(file f, string name, string date) throws exception { parametervalue<overviewpolicy> policy = abstractgridformat.overview_policy .createvalue(); policy.setvalue(overviewpolicy.ignore); // read 4 tiles worth of data @ once disk... parametervalue<string> gridsize = abstractgridformat.suggested_tile_size.createvalue(); //gridsize.setvalue(512 * 4 + "," + 512); // setting read type: use jai imageread (true) or imagereaders read methods (false) parametervalue<boolean> usejairead = abstractgridformat.use_jai_imageread.createvalue(); usejairead.setvalue(true); //reader.read(new generalparametervalue[] { policy, gridsize, usejairead }); // line throws error gridcoverage2d image = new geotiffreader(f).read(new generalparametervalue[]{policy, gridsize, usejairead}); rectangle2d bounds2d = image.getenvelope2d().getbounds2d(); bounds2d.getcenterx(); // calculate zoom level image gridgeometry2d geometry = image.getgridgeometry(); bufferedimage img = imageio.read(f); // colormodel colormodel = img.getcolormodel( writableraster raster = img.getraster(); int numbands = raster.getnumbands(); int w = img.getwidth(); int h = img.getheight(); outer: (int = 0; < w; i++) {//width... (int j = 0; j < h; j++) { double[] latlon = geo(geometry, i, j); double lat = latlon[0]; double lon = latlon[1]; double s = 0d; string originalbands = ""; (int k = 0; k < numbands; k++) { double d = raster.getsampledouble(i, j, k); originalbands += d + ","; s += d; } originalbands = originalbands.substring(0, originalbands.length() - 1); if (s.compareto(0d) == 0) { continue; } string geohash = geohashutils.encodelatlon(lat, lon); //here bands, lat, long, geohash, etc.... } } } private static double[] geo(gridgeometry2d geometry, int x, int y) throws exception { //int zoomlevel = 1; envelope2d pixelenvelop = geometry.gridtoworld(new gridenvelope2d(x, y, 1, 1)); // pixelenvelop.getcoordinatereferencesystem().getname().getcodespace(); return new double[]{pixelenvelop.getcentery(), pixelenvelop.getcenterx()}; } }
jdk jars
other jars
i added classpath variable geotools jars
edit:
my jai working without geotools integration, when add gt-geotiff-14.4.jar
try add jai-core-1.1.3.jar
conflicts jai-core.jar
in jdk 1.7. removed jai-core-1.1.3.jar
, related jars still gives me same error.
finally worked when removed geotiff jai-core-1.1.3.jar
,jai-codec-1.1.3.jar
, jai-imageio-1.1.jar
files , added new class jai-ext's gt-utility class files. copied github , added src of project.gt-utility 1 missing. jars conflicting too.
Comments
Post a Comment