0

我需要使用系统网络摄像头拍摄照片。为此,我正在使用webcam capture library. 它包含三个 jar 文件。我想在单个jar应用程序中打包所有东西,包括依赖 jar。

所以,我整理解压依赖的jar文件,将它们放在srcnetbeans项目的文件夹中。所以,我提取了它们。其中两个以相同的包名开头org,所以我提取并合并了它们。重要的第三个包以包开头com。我已将这三个目录放在src我的netbeans项目的文件夹中。

现在的问题是netbeans,说这个包不存在。但是,在 Windows 中编译时是同一个项目。command line编译并成功运行,一切正常。

但是,当我将有问题的库作为 jar 添加到项目中时,它工作正常,只是将其提取并放置在src导致问题的文件夹中。

为什么会发生此错误,为什么会出现此错误netbeans,如何解决此问题?

我的代码:

package screen;
import com.github.sarxos.webcam.*;     **//Error here**
import com.github.sarxos.webcam.log.*;  **// Error here**
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class Util extends TimerTask{
        private String filePath;
        private String type;
        private Timer timer;
        private Webcam webcam;
        public Util(String path,String type){
            this.timer=new Timer("Capture Timer");
            this.filePath=path;
            this.type=type;
            this.webcam=Webcam.getDefault();
        }
    public void capture() throws IOException{
           if(webcam!=null){
                webcam.open();
                BufferedImage image=webcam.getImage();
                Date date=new Date();
                ImageIO.write(image,type,new File(filePath+"_"+date.toString().replace(' ','_').replace(':','-')+"."+type.toLowerCase()));
                webcam.close();
           }
           else{
               webcam=Webcam.getDefault();
           }
    }
        public  void startCapturing(int period){
            this.timer.schedule(this,0,period);
        }
        public void stopCapturing(){
            timer.cancel();
        }
        public void run(){
                try{
                    capture();
                    System.out.println("Doing");
                }catch(Exception e){
                    e.printStackTrace();
                }
        }
        public static void main(String args[]){
            Util u=new Util("n082430_","PNG");
            u.startCapturing(60000);
        }
}
4

0 回答 0