Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

Saturday, September 30, 2023

How to fix (Access is denied)? Example

Earlier my impression was that (Access is denied) comes when you try to read a text or binary file for which you don't have permission from the Java program but this can also come while you are using the jar command. jar command internally uses class to open any jar or war file which can throw (Access is denied). I was trying to see the contents of the war file which was created using a recent build when I stumble upon this error, see the exact command below:

test@dev454:war-store/target jar -tvf maven-eclipse-web-demo maven-eclipse-web-demo (Access is denied)
        at Method)

Possible cause of (Access is denied):

Here are some of the possible cause I checked immediately:

1. See if you have permission to read the jar file or not

this is the most obvious reason for (Access is denied) exception and I didn't have sufficient permission so I immediately provided read, write and execute permission to war file and tried again
but it didn't help it was still throwing that exception.

2. See if some other process is using that file

This could be another possible reason for " (Access is denied)". in my case I had earlier tried the "tar" command to read that file which I suspect hasn't been released the file. because after a few try it was solved.


How to fix (Access is denied) (Access is denied) obviously shows something is wrong with file permissions. if you have sufficient file permission than possible reason both in Windows and Unix is might be some other process is using that file which may prevent jar command to list down contents of war file or extract content of war file. 

By the way if you are not aware of how to see contents of war file than its good to know that jar file can be used to see contents of both .jar and .war file. I haven't tested .ear file but I am sure jar command can extract that as well because they are kind of zip file.

Other Java troubleshooting tutorials you may like

Let me know if you have faced this issue and not able to solve it, happy to help. Please post the full error in comments and provide context like what you are doing and when you get this error, this will help me to solve your problem. 


Unknown said...


EN este archivo .- C:\Users\cjimenez.DGSGIF\AppData\Roaming\JDeveloper\system12.\DefaultDomain\bin

Anonymous said...

I am getting FileNotFoundException, system cannot find the path, while runing tests with Maven, can you please advise? I have config files in folder under root maven project. Its a multi-module maven project and config file are under one module but maven cannot find and load them while running test and throwing this

Post a Comment