Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exception in thread "main" java.lang.NoClassDefFoundError:

843810Sep 26 2003 — edited Nov 20 2003
HI..
I don't know y i get this error when i try to run this program which i got from a site:


Exception in thread "main" java.lang.NoClassDefFoundError:
imagedata/ImageInfo

i have worked with alot of java programs and they all seem to work fine.

note: i write my programs on textpad so i compile and run them from there i have never done it from dos and i have read about setting the classpath but it didn't work)
can anyone help me??????????

this is the code:


package imagedata;

import java.awt.Transparency;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.SampleModel;
import java.io.File;

import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;

/**
* This class displays basic information about the image.
*/
public class ImageInfo
{
/**
* The application entry point.
* @param args the command line arguments.
*/
public static void main(String[] args)
{
// We need one argument: the image filename.
if (args.length != 1)
{
System.err.println("Usage: java imagedata.ImageInfo image");
System.exit(0);
}
// Open the image (using the name passed as a command line parameter)
PlanarImage pi = JAI.create("fileload", args[0]);
// Display image data. First, the image size (non-JAI related).
File image = new File(args[0]);
System.out.println("Image file size:"+image.length()+" bytes.");
// Now let's display the image dimensions and coordinates.
System.out.print("Dimensions: ");
System.out.print(pi.getWidth()+"x"+pi.getHeight()+" pixels");
System.out.println(" (from "+pi.getMinX()+","+pi.getMinY()+" to " +
pi.getMaxX()+","+pi.getMaxY()+")");
// Tiles number, dimensions and coordinates.
System.out.print("Tiles:");
System.out.print(pi.getTileWidth()+"x"+pi.getTileHeight()+" pixels"+
" ("+pi.getNumXTiles()+"x"+pi.getNumYTiles()+" tiles)");
System.out.print(" (from "+pi.getMinTileX()+","+pi.getMinTileY()+" to "+
pi.getMaxTileX()+","+pi.getMaxTileY()+")");
System.out.println(" offset: "+pi.getTileGridXOffset()+","+pi.getTileGridXOffset());
// Display info about the SampleModel of the image.
SampleModel sm = pi.getSampleModel();
System.out.println("Number of bands: "+sm.getNumBands());
System.out.print("Data type: ");
switch(sm.getDataType())
{
case DataBuffer.TYPE_BYTE: System.out.println("byte"); break;
case DataBuffer.TYPE_SHORT: System.out.println("short"); break;
case DataBuffer.TYPE_USHORT: System.out.println("unsigned short"); break;
case DataBuffer.TYPE_INT: System.out.println("int"); break;
case DataBuffer.TYPE_FLOAT: System.out.println("float"); break;
case DataBuffer.TYPE_DOUBLE: System.out.println("double"); break;
case DataBuffer.TYPE_UNDEFINED: System.out.println("undefined"); break;
}
// Display info about the ColorModel of the image.
ColorModel cm = pi.getColorModel();
System.out.println("Number of color components: "+cm.getNumComponents());
System.out.println("Bits per pixel: "+cm.getPixelSize());
System.out.print("Transparency: ");
switch(cm.getTransparency())
{
case Transparency.OPAQUE: System.out.println("opaque"); break;
case Transparency.BITMASK: System.out.println("bitmask"); break;
case Transparency.TRANSLUCENT: System.out.println("translucent"); break;
}
}
}


Thanxxxxxxxxxxxxxxxxxxx:)

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 18 2003
Added on Sep 26 2003
2 comments
458 views