我在网上下载了如下代码,在myeclipse中运行时,它提示如下错误:
Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
Access restriction: The type JPEGCodec is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
Access restriction: The method createJPEGEncoder(OutputStream) from the type JPEGCodec is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
Access restriction: The method encode(BufferedImage) from the type JPEGImageEncoder is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar
但C:\Java\jre1.6.0_07\lib\rt.jar是存在的啊,麻烦哪位给你指明一下?
//缩略图实现,将图片(jpg,gif,bmp等等)真实的变成想要的大小
import java.io.*;
import java.util.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.*;
import java.awt.*;
import java.net.*;
import java.applet.*;
import java.sql.*;
//缩略图类,
//本java类能将jpg图片文件,进行等比或非等比的大小转换。
//具体使用方法
//s_pic(大图片路径,生成小图片路径,大图片文件名,生成小图片文名,生成小图片宽度,生成小图片高度,是否等比缩放(默认为true))
public class thumbs{
String InputDir; //输入图路径
String OutputDir; //输出图路径
String InputFileName; //输入图文件名
String OutputFileName; //输出图文件名
int OutputWidth = 80; //默认输出图片宽
int OutputHeight = 80; //默认输出图片高
int rate = 0;
boolean proportion = true; //是否等比缩放标记(默认为等比缩放)
public thumbs() {
//初始化变量
InputDir = "";
OutputDir = "";
InputFileName = "";
OutputFileName = "";
OutputWidth = 80;
OutputHeight = 80;
rate = 0;
}
public void setInputDir(String InputDir) {
this.InputDir = InputDir;
}
public void setOutputDir(String OutputDir) {
this.OutputDir = OutputDir;
}
public void setInputFileName(String InputFileName) {
this.InputFileName = InputFileName;
}
public void setOutputFileName(String OutputFileName) {
this.OutputFileName = OutputFileName;
}
public void setOutputWidth(int OutputWidth) {
this.OutputWidth = OutputWidth;
}
public void setOutputHeight(int OutputHeight) {
this.OutputHeight = OutputHeight;
}
public void setW_H(int width, int height) {
this.OutputWidth = width;
this.OutputHeight = height;
}
public String s_pic() {
BufferedImage image;
String NewFileName;
//建立输出文件对象
File file = new File(OutputDir + OutputFileName);
FileOutputStream tempout = null;
try {
tempout = new FileOutputStream(file);
}
catch (Exception ex) {
System.out.println(ex.toString());
}
Image img = null;
Toolkit tk = Toolkit.getDefaultToolkit();