请高手指点,我现在是用JAVA写代码的一个截屏的程序,然后用VJ++封装的成DLL组件,现在条件是,环境变量已经设置好,在ECLIPSE环境下运行是没问题的,但是在ASP页面调用这个组件的时候,对象创建成功,但是调用这个对象截屏方法的时候,就出现这个样的错误:
Java 异常 错误 '80004005' java.lang.NoClassDefFoundError /TEST/test1.asp,行 5
源代码如下:import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* This class is designed to be packaged with a COM DLL output format.
* The class has no standard entry points, other than the constructor.
* Public methods will be exposed as methods on the default COM interface.
* @com.register ( clsid=C2DB3B44-7D19-459F-812E-C951B7DF3C39, typelib=662F96D4-EF82-44F0-850F-918D740D676D )
*/public class CaptureScreen
{
// TODO: Add additional methods and code here
private Robot robot = null;
private Rectangle scrRect = null;
BufferedImage bufImg = null;
String fileName ;
//设置平台的截取尺寸
int arraySize[][] = {{22,95,390,553},{412,95,390,553}} ;
//类初始化
public void captureScreen1()
{
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); // 桌面屏幕尺寸
for(int i = 0;i<arraySize.length;i++){
scrRect = new Rectangle(arraySize[i][0],arraySize[i][1], arraySize[i][2], arraySize[i][3]);
captureScreen(i);
}
}
//抓屏函数
public void captureScreen(int i){
try
{
this.robot = new Robot();
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
try
{
this.bufImg = new Robot().createScreenCapture(scrRect);
}
catch (Exception e)
{
e.printStackTrace();
}
try {
FileOutputStream fileStream =
new FileOutputStream("E:\\Test"+i+".jpg");
JPEGImageEncoder encoder =
JPEGCodec.createJPEGEncoder(fileStream);
encoder.encode(bufImg);
fileStream.close();
}
catch (Exception e) {
System.out.println("Error saving JPEG file!");
}
}
} /**
* NOTE: To add auto-registration code, refer to the documentation
* on the following method
* public static void onCOMRegister(boolean unRegister) {}
*/
Java 异常 错误 '80004005' java.lang.NoClassDefFoundError /TEST/test1.asp,行 5
源代码如下:import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* This class is designed to be packaged with a COM DLL output format.
* The class has no standard entry points, other than the constructor.
* Public methods will be exposed as methods on the default COM interface.
* @com.register ( clsid=C2DB3B44-7D19-459F-812E-C951B7DF3C39, typelib=662F96D4-EF82-44F0-850F-918D740D676D )
*/public class CaptureScreen
{
// TODO: Add additional methods and code here
private Robot robot = null;
private Rectangle scrRect = null;
BufferedImage bufImg = null;
String fileName ;
//设置平台的截取尺寸
int arraySize[][] = {{22,95,390,553},{412,95,390,553}} ;
//类初始化
public void captureScreen1()
{
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); // 桌面屏幕尺寸
for(int i = 0;i<arraySize.length;i++){
scrRect = new Rectangle(arraySize[i][0],arraySize[i][1], arraySize[i][2], arraySize[i][3]);
captureScreen(i);
}
}
//抓屏函数
public void captureScreen(int i){
try
{
this.robot = new Robot();
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
try
{
this.bufImg = new Robot().createScreenCapture(scrRect);
}
catch (Exception e)
{
e.printStackTrace();
}
try {
FileOutputStream fileStream =
new FileOutputStream("E:\\Test"+i+".jpg");
JPEGImageEncoder encoder =
JPEGCodec.createJPEGEncoder(fileStream);
encoder.encode(bufImg);
fileStream.close();
}
catch (Exception e) {
System.out.println("Error saving JPEG file!");
}
}
} /**
* NOTE: To add auto-registration code, refer to the documentation
* on the following method
* public static void onCOMRegister(boolean unRegister) {}
*/
就算你的程序能运行,大概抓到的也是服务器端的,除非你写个 APPLET 才有可能 (大概还需要授权)。