JNAを使用してLinuxサーバーにプログラムでアップロードされたファイルのファイルパーミッションを変更しようとしていました。私の参照はこれとこれです。そして私のコードを以下に示します。そして、Operation not permitted例外が発生しています。この問題を解決する方法はありますか?アップロードされたファイルの権限をプログラムで変更する他の方法はありますか?または、指定されたファイル権限でファイルをアップロードする方法はありますか?私はJava1.5を使用しています。jna.jarを入れましたが/public_html/WEB-INF/lib、初心者向けの優れたJNAチュートリアルを提案できる人はいますか?
JSPコード(テスト用)
<%@page import="cc.FileModifierLinux"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
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);
}
%>
</body>
</html>
使用したクラス
package cc;
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);
}
例外
完全な例外の詳細については、これを参照してください
 org.apache.jasper.JasperException: Exception in JSP: /index_check.jsp:23
20: {
21:     
22:     
23:     FileModifierLinux flx=new FileModifierLinux();
24:     String pathX = getServletContext().getRealPath("/testpage.jsp");
25:     flx.Update(pathX);
26:     out.println("No Exception");
Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
javax.servlet.ServletException: Could not initialize class com.sun.jna.Native