无法解决软件包org.apache.commons.vfs异常 [英] Cannot resolve package org.apache.commons.vfs exception

查看:126
本文介绍了无法解决软件包org.apache.commons.vfs异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码中出现一个异常,说 org.apache.commons.vfs。*无法解决。有人可以解释为什么会发生这种情况,以及如何解决它。



这是我的代码...

 导入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。*;

公共类watchDirectory实现FileListener {
public static void watchDir(String a){
FileSystemManager fsManager = VFS.getManager();
FileObject listendir = fsManager.resolveFile( / home / username / monitored /);

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


解决方案

您缺少以下库您的构建路径。遵循将库添加到项目的构建路径中的步骤

右键单击项目根,选择构建路径,在其下选择配置构建路径


然后选择库标签,在该标签下单击添加外部jar

>
然后浏览jar文件并将其添加到构建路径,然后刷新您的项目。如果您没有jar文件,则可以从此处下载它。 p>

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();
    }

解决方案

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

这篇关于无法解决软件包org.apache.commons.vfs异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆