I was trying to implement JNA. I have used the following code for the testing purpose. Now I am getting an exception. Please correct me if I am using an incorrect method or if there are any problems in my testing code.
My reference tutorials were this and this
My class 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);
}
My page:
<%
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);
}
%>
Exception:
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)
Did you import
the class in the index.jsp
? like:
<%@page import="com.somepackage.FileModifierLinux "%>