Cannot resolve package org.apache.commons.vfs exception

安稳与你 提交于 2019-12-11 07:48:50

问题


I am getting an exception in my code saying org.apache.commons.vfs.* cannot be resolved. Could someone please explain why this is occurring, and how it can be fixed.

This is my code...

import org.apache.commons.vfs.FileChangeEvent;
import org.apache.commons.vfs.FileListener;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.VFS;
import org.apache.commons.vfs.impl.DefaultFileMonitor;
import com.sample.*;

public class watchDirectory  implements FileListener{
    public static void watchDir(String a){
        FileSystemManager fsManager = VFS.getManager();
        FileObject listendir = fsManager.resolveFile("/home/username/monitored/");

        DefaultFileMonitor fm = new DefaultFileMonitor(new CustomFileListener());
        fm.setRecursive(true);
        fm.addFile(listendir);
        fm.start();
    }

回答1:


You are missing the library in your build path. Follow the steps to add the library into your project's build path

Right click on the project root, select "build path", under that select "configure build path"

Then select the library tab, under that click on "Add external jars"


Then browse for the jar file and add it to the build path, then refresh your project. If you don't have the jar file, you can download it from here

来源:https://stackoverflow.com/questions/7117343/cannot-resolve-package-org-apache-commons-vfs-exception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!