0

我试图实现 JNA。我已将以下代码用于测试目的。现在我遇到了一个例外。如果我使用了不正确的方法或者我的测试代码有任何问题,请纠正我。

我的参考教程是这个这个

我的班级 FileModifierLinux:

import com.sun.jna.Library;
import com.sun.jna.Native;

public class FileModifierLinux {
     CLibrary libc = (CLibrary) Native.loadLibrary("c", CLibrary.class);
    public void Update(String pth) {
        libc.chmod(pth, 0755);
    }
}
interface CLibrary extends Library {
    public int chmod(String path, int mode);
}

我的页面:

<%

try
{
    FileModifierLinux flx=new FileModifierLinux();
    String pathX = getServletContext().getRealPath("/testpage.jsp");
    flx.Update(pathX);
    out.println("No Exception");
}
catch(Exception exp)
{
    out.println("exp :"+exp);
}
%>

例外:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 15 in the jsp file: /index.jsp
Generated servlet error:
FileModifierLinux cannot be resolved to a type

An error occurred at line: 15 in the jsp file: /index.jsp
Generated servlet error:
FileModifierLinux cannot be resolved to a type

    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
4

1 回答 1

0

import上课了index.jsp吗?像:

<%@page import="com.somepackage.FileModifierLinux "%>
于 2012-08-01T12:52:37.827 回答