Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:48:58+00:00 2026-06-09T08:48:58+00:00

I was trying to change the file permission of programmically uploaded files on linux

  • 0

I was trying to change the file permission of programmically uploaded files on linux server using JNA. My references are this and this. And my code is given below. And am getting a Operation not permitted exception. Is there any way to resolve this problem? Is there any other way to programmicaly change the permission of the uploaded file? Or is there any way to upload the file with a specified file permission. I am using java 1.5. I have put jna.jar in /public_html/WEB-INF/lib, can anyone suggest a good JNA tutorial for beginners?

JSP code (for testing)

<%@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>

Class Used

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

Exception

for full exception details refer this

 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:49:00+00:00Added an answer on June 9, 2026 at 8:49 am

    You likely need to install libjnidispatch.so on your server such that it is available in java.library.path so that JNA can load it. The exception thrown is due to JNA not finding that library and attempting to unpack it from its own jar file.

    Based on the original exception, your servlet won’t be allowed to load native libraries except from designated, protected locations. Check your servlet container documentation for how to install and make available for loading JNI libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey well I'm trying to change the url structure using the htaccess file and
I'm trying to use preg_replace to change the formatting of a TeX file. This
I want to change the file permission for all the files from my current
I'm trying to change some config file user settings values in my WPF application,
I am trying to change an XML file from one format to another and
I'm trying to change some text in a .CSV file. StreamReader sReader = new
i am trying to change user agent in php.ini file as follows. user_agent=Mozilla/5.0 (iPhone
i am trying to change an input type hidden into input type file onclick
i need to be able to change the IP address of a server using
I am trying to connect to an mdf file using the following connection string:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.