Java ошибка unable to access jarfile

I want to execute my program without using an IDE.
I’ve created a jar file and an exectuable jar file. When
I double click the exe jar file, nothing happens, and when I try to use the command in cmd it gives me this:

Error: Unable to access jarfile <path>

I use the command: java -jar Calculator.jar

How I created the jar:

  1. Right click on project folder (Calculator)
  2. Select
  3. Click on Java Folder and select «Exectuable Jar File», then select next
  4. Launch Configuration: Main — Calculator
  5. Create Export Destination
  6. Hit «Finish» and profit! Well, not really.

Raedwald's user avatar

Raedwald

46.7k44 gold badges151 silver badges238 bronze badges

asked Aug 14, 2012 at 0:01

Joseph Smith's user avatar

Joseph SmithJoseph Smith

3,2435 gold badges20 silver badges18 bronze badges

12

I had encountered this issue when I had run my Jar file as

java -jar TestJar

instead of

java -jar TestJar.jar

Missing the extension .jar also causes this issue.

answered Sep 16, 2014 at 10:26

Vinay Kadalagi's user avatar

Vinay KadalagiVinay Kadalagi

1,3151 gold badge8 silver badges11 bronze badges

4

Fixed

I just placed it in a different folder and it worked.

Paolo Forgia's user avatar

Paolo Forgia

6,5928 gold badges47 silver badges58 bronze badges

answered Aug 15, 2012 at 4:05

Joseph Smith's user avatar

Joseph SmithJoseph Smith

3,2435 gold badges20 silver badges18 bronze badges

9

[Possibly Windows only]

Beware of spaces in the path, even when your jar is in the current working directory. For example, for me this was failing:

java -jar myjar.jar

I was able to fix this by givng the full, quoted path to the jar:

java -jar "%~dp0\myjar.jar" 

Credit goes to this answer for setting me on the right path….

Community's user avatar

answered Mar 15, 2016 at 3:15

Robert Brown's user avatar

Robert BrownRobert Brown

10.9k7 gold badges35 silver badges40 bronze badges

2

I had this issue under CygWin in Windows. I have read elsewhere that Java does not understand the CygWin paths (/cygdrive/c/some/dir instead of C:\some\dir) — so I used a relative path instead: ../../some/dir/sbt-launch.jar.

answered Aug 4, 2016 at 17:18

radumanolescu's user avatar

radumanolescuradumanolescu

4,0692 gold badges31 silver badges45 bronze badges

3

I had the same issue when trying to launch the jar file. The path contained a space, so I had to place quotes around. Instead of:

java -jar C:\Path to File\myJar.jar

i had to write

java -jar "C:\Path to File\myJar.jar"

Dharman's user avatar

Dharman

31.1k25 gold badges86 silver badges137 bronze badges

answered Sep 6, 2015 at 18:05

benez's user avatar

2

Just came across the same problem trying to make a bad USB…

I tried to run this command in admin cmd

java -jar c:\fw\ducky\duckencode.jar -I c:\fw\ducky\HelloWorld.txt  -o c:\fw\ducky\inject.bin

But got this error:

Error: unable to access jarfile c:\fw\ducky\duckencode.jar

Solution

1st step

Right click the jarfile in question. Click properties.
Click the unblock tab in bottom right corner.
The file was blocked, because it was downloaded and not created on my PC.

2nd step

In the cmd I changed the directory to where the jar file is located.

cd C:\fw\ducky\

Then I typed dir and saw the file was named duckencode.jar.jar

So in cmd I changed the original command to reference the file with .jar.jar

java -jar c:\fw\ducky\duckencode.jar.jar -I c:\fw\ducky\HelloWorld.txt  -o c:\fw\ducky\inject.bin

That command executed without error messages and the inject.bin I was trying to create was now located in the directory.

Hope this helps.

mcls's user avatar

mcls

9,1312 gold badges29 silver badges28 bronze badges

answered Oct 23, 2015 at 20:26

Leon thomas's user avatar

2

None of the provided answers worked for me on macOS 11 Big Sur. The problem turned out to be that programs require special permission to access the Desktop, Documents, and Downloads folders, and Java breaks both the exception for directly opened files and the permission request popup.

Fixes:

  • Move the .jar into a folder that isn’t (and isn’t under) Documents, Desktop, or Downloads.
  • Manually grant the permission. Go to System Preferences → Security and Privacy → Privacy → Files and Folders → java, and check the appropriate folders.

answered Jan 27, 2021 at 9:50

twhb's user avatar

twhbtwhb

4,3142 gold badges20 silver badges23 bronze badges

If you are using OSX, downloaded files are tagged with a security flag that prevents unsigned applications from running.

to check this you can view extended attributes on the file

$ ls -l@
-rw-r--r--@ 1 dave  staff  17663235 13 Oct 11:08 server-0.28.2-java8.jar
com.apple.metadata:kMDItemWhereFroms         619
com.apple.quarantine          68

You can then clear the attributes with

xattr -c file.jar

answered Oct 13, 2017 at 10:24

nick fox's user avatar

nick foxnick fox

5708 silver badges15 bronze badges

1

I had a similar problem and I even tried running my CMD with administrator rights, but it did not solve the problem.

The basic thing is to make sure to change the Directory in cmd to the current directory where your jar file is.

Do the following steps:

  1. Copy jar file to Desktop.

  2. Run CMD

  3. Type command cd desktop

  4. Then type java -jar filename.jar

This should work.


Edit: From JDK-11 onwards ( JEP 330: Launch Single-File Source-Code Programs )

Since Java 11, java command line tool has been able to run a single-file source-code directly. e.g.

java filename.java

Gabor Dicso's user avatar

answered Dec 26, 2018 at 6:22

Vishwa Ratna's user avatar

Vishwa RatnaVishwa Ratna

5,5975 gold badges33 silver badges55 bronze badges

It can also happen if you don’t properly supply your list of parameters. Here’s what I was doing:

java -jar test@gmail.com testing_subject file.txt test_send_emails.jar

Instead of the correct version:

java -jar test_send_emails.jar test@gmail.com testing_subject file.txt

answered Jul 15, 2015 at 8:06

Buffalo's user avatar

BuffaloBuffalo

3,8618 gold badges44 silver badges69 bronze badges

This worked for me.

cd /path/to/the/jar/

java -jar ./Calculator.jar

answered Nov 15, 2016 at 18:18

Bastian Cáceres Pino's user avatar

For me it happens if you use native Polish chars in foldername that is in the PATH.
So maybe using untypical chars was the reason of the problem.

answered Oct 8, 2015 at 9:52

Huxwell's user avatar

HuxwellHuxwell

1712 silver badges14 bronze badges

sometime it happens when you try to (run or create) a .jar file under /libs folder by right click it in android studio. you can select the dropdown in top of android stuio and change it to app. This will work

enter image description here

answered Feb 17, 2016 at 10:44

anand krish's user avatar

anand krishanand krish

4,2974 gold badges44 silver badges47 bronze badges

My particular issue was caused because I was working with directories that involved symbolic links (shortcuts). Consequently, trying java -jar ../../myJar.jar didn’t work because I wasn’t where I thought I was.

Disregarding relative file paths fixed it right up.

answered Nov 18, 2015 at 23:31

MattSayar's user avatar

MattSayarMattSayar

2,0786 gold badges23 silver badges28 bronze badges

In my case the suggested file name to be used was jarFile*.jar in the command line. The file in the folder was jarFile-1.2.3.jar . So I renamed the file to jarFile. Then I used jarFile.jar instead of jarFile*.jar and then the problem got resolved

answered Jan 22, 2017 at 6:41

suku's user avatar

sukusuku

10.5k16 gold badges75 silver badges120 bronze badges

1

It can happen on a windows machine when you have spaces in the names of the folder. The solution would be to enter the path between » «.
For example:

java -jar c:\my folder\x.jar    --> 
java -jar "c:\my folder\x.jar"

Sundar's user avatar

Sundar

4,5906 gold badges36 silver badges61 bronze badges

answered Oct 31, 2017 at 8:57

assaf's user avatar

assafassaf

211 bronze badge

1

To avoid any permission issues, try to run it as administrator. This worked for me on Win10.

answered Mar 14, 2018 at 15:14

Gico's user avatar

GicoGico

1,2762 gold badges15 silver badges30 bronze badges

1

I know this thread is years ago and issue was fixed too. But I hope this would helps someone else in future since I’ve encountered some similar issues while I tried to install Oracle WebLogic 12c and Oracle OFR in which its installer is in .jar format. For mine case, it was either didn’t wrap the JDK directory in quotes or simply typo.

Run Command Prompt as administrator and execute the command in this format. Double check the sentence if there is typo.

"C:\Program Files\Java\jdk1.xxxxx\bin\java" -jar C:\Users\xxx\Downloads\xxx.jar

If it shows something like JRE 1.xxx is not a valid JDK Java Home, make sure the System variables for JAVA_HOME in Environment Variables is pointing to the correct JDK directory. JDK 1.8 or above is recommended (2018).

A useful thread here, you may refer it: Why its showing your JDK c:program files\java\jre7 is not a valid JDK while instaling weblogic server?

answered Oct 23, 2018 at 6:54

not_Prince's user avatar

not_Princenot_Prince

3203 silver badges17 bronze badges

For me it happen because i run it with default java version (7) and not with compiled java version (8) used to create this jar.

So i used:

%Java8_64%\bin\java -jar myjar.jar

Instead of java 7 version:

java -jar myjar.jar

answered Feb 9, 2020 at 19:19

Adir Dayan's user avatar

Adir DayanAdir Dayan

1,32813 silver badges21 bronze badges

I had a similar problem where TextMate or something replaced the double quotes with the unicode double quotes.

Changing my SELENIUM_SERVER_JAR from the unicode double quotes to regular double quotes and that solved my problem.

answered Mar 30, 2016 at 18:05

TankorSmash's user avatar

TankorSmashTankorSmash

12.2k6 gold badges68 silver badges106 bronze badges

this is because you are looking for the file in the wrong path
1. look for the path of the folder where you placed the file
2. change the directory cd in cmd use the right path

answered Jun 19, 2016 at 21:39

felipe's user avatar

0

I use NetBeans and had the same issue. After I ran build and clean project my program was executable. The Java documentation says that the build/clean command is for rebuilding the project from scratch basically and removing any past compiles. I hope this helps. Also, I’d read the documentation. Oracle has NetBeans and Java learning trails. Very helpful. Good luck!

answered Jul 16, 2017 at 13:43

user8315373's user avatar

Maybe you have specified the wrong version of your jar.

answered Sep 21, 2017 at 21:52

cosbor11's user avatar

cosbor11cosbor11

14.8k10 gold badges54 silver badges69 bronze badges

I finally pasted my jar file into the same folder as my JDK so I didn’t have to include the paths. I also had to open the command prompt as an admin.

  1. Right click Command Prompt and «Run as administrator»
  2. Navigate to the directory where you saved your jdk to
  3. In the command prompt type: java.exe -jar <jar file name>.jar

answered Jan 14, 2020 at 15:04

Michaela Burns's user avatar

Keep the file in same directory where you are extracting it. That worked for me.

answered Jan 22, 2020 at 2:18

Aishwary joshi's user avatar

Aishwary joshiAishwary joshi

711 gold badge1 silver badge4 bronze badges

This is permission issue, see if the directory is under your User.
That’s why is working in another folder!

answered Jul 31, 2020 at 13:05

Dimitrios's user avatar

DimitriosDimitrios

1,15311 silver badges10 bronze badges

Rename the jar file and try

Explanation :
yes, I know there are many answers still I want to add one point here which I faced.

I built the jar and I moved it into the server where I deploy (This is the normal process)
here the file name which I moved already existed in the server, here the file will override obviously right. In this case, I faced this issue.
maybe at the time of overriding there can be a permission copy issue.

Hope this will help someone.

answered Aug 3, 2020 at 14:12

Sainath Pabba's user avatar

If you are on WSL (Windows Subsystem for Linux), and following a guide which say, says this:

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

You actually need to specify the full path, even though you’ve provided it in the java.library.path part.

java -Djava.library.path=/mnt/c/dynamodb_local/DynamoDBLocal_lib -jar /mnt/c/dynamodb_local/DynamoDBLocal.jar -sharedDb

answered Apr 21, 2020 at 14:10

AncientSwordRage's user avatar

AncientSwordRageAncientSwordRage

7,13619 gold badges90 silver badges175 bronze badges

2

Have you tried to run it under administrator privoleges?
meaning, running the command in «Run As» and then select administrator with proper admin credentials

worked for me

answered May 14, 2019 at 20:28

Nick_Stubborn_Mex.'s user avatar

I was trying this:

After giving the file read, write, execute priviledges:

chmod 777 java-repl.jar

alias jr="java -jar $HOME/Dev/java-repl/java-repl.jar"

Unable to access bla bla…, this was on Mac OS though

So I tried this:

alias jr="cd $HOME/Dev/java-repl/ && java -jar java-repl.jar"

Litisqe Kumar's user avatar

answered Jul 23, 2019 at 8:53

Kinglee's user avatar

KingleeKinglee

531 silver badge8 bronze badges

I want to execute my program without using an IDE.
I’ve created a jar file and an exectuable jar file. When
I double click the exe jar file, nothing happens, and when I try to use the command in cmd it gives me this:

Error: Unable to access jarfile <path>

I use the command: java -jar Calculator.jar

How I created the jar:

  1. Right click on project folder (Calculator)
  2. Select
  3. Click on Java Folder and select «Exectuable Jar File», then select next
  4. Launch Configuration: Main — Calculator
  5. Create Export Destination
  6. Hit «Finish» and profit! Well, not really.

Raedwald's user avatar

Raedwald

46.7k44 gold badges151 silver badges238 bronze badges

asked Aug 14, 2012 at 0:01

Joseph Smith's user avatar

Joseph SmithJoseph Smith

3,2435 gold badges20 silver badges18 bronze badges

12

I had encountered this issue when I had run my Jar file as

java -jar TestJar

instead of

java -jar TestJar.jar

Missing the extension .jar also causes this issue.

answered Sep 16, 2014 at 10:26

Vinay Kadalagi's user avatar

Vinay KadalagiVinay Kadalagi

1,3151 gold badge8 silver badges11 bronze badges

4

Fixed

I just placed it in a different folder and it worked.

Paolo Forgia's user avatar

Paolo Forgia

6,5928 gold badges47 silver badges58 bronze badges

answered Aug 15, 2012 at 4:05

Joseph Smith's user avatar

Joseph SmithJoseph Smith

3,2435 gold badges20 silver badges18 bronze badges

9

[Possibly Windows only]

Beware of spaces in the path, even when your jar is in the current working directory. For example, for me this was failing:

java -jar myjar.jar

I was able to fix this by givng the full, quoted path to the jar:

java -jar "%~dp0\myjar.jar" 

Credit goes to this answer for setting me on the right path….

Community's user avatar

answered Mar 15, 2016 at 3:15

Robert Brown's user avatar

Robert BrownRobert Brown

10.9k7 gold badges35 silver badges40 bronze badges

2

I had this issue under CygWin in Windows. I have read elsewhere that Java does not understand the CygWin paths (/cygdrive/c/some/dir instead of C:\some\dir) — so I used a relative path instead: ../../some/dir/sbt-launch.jar.

answered Aug 4, 2016 at 17:18

radumanolescu's user avatar

radumanolescuradumanolescu

4,0692 gold badges31 silver badges45 bronze badges

3

I had the same issue when trying to launch the jar file. The path contained a space, so I had to place quotes around. Instead of:

java -jar C:\Path to File\myJar.jar

i had to write

java -jar "C:\Path to File\myJar.jar"

Dharman's user avatar

Dharman

31.1k25 gold badges86 silver badges137 bronze badges

answered Sep 6, 2015 at 18:05

benez's user avatar

2

Just came across the same problem trying to make a bad USB…

I tried to run this command in admin cmd

java -jar c:\fw\ducky\duckencode.jar -I c:\fw\ducky\HelloWorld.txt  -o c:\fw\ducky\inject.bin

But got this error:

Error: unable to access jarfile c:\fw\ducky\duckencode.jar

Solution

1st step

Right click the jarfile in question. Click properties.
Click the unblock tab in bottom right corner.
The file was blocked, because it was downloaded and not created on my PC.

2nd step

In the cmd I changed the directory to where the jar file is located.

cd C:\fw\ducky\

Then I typed dir and saw the file was named duckencode.jar.jar

So in cmd I changed the original command to reference the file with .jar.jar

java -jar c:\fw\ducky\duckencode.jar.jar -I c:\fw\ducky\HelloWorld.txt  -o c:\fw\ducky\inject.bin

That command executed without error messages and the inject.bin I was trying to create was now located in the directory.

Hope this helps.

mcls's user avatar

mcls

9,1312 gold badges29 silver badges28 bronze badges

answered Oct 23, 2015 at 20:26

Leon thomas's user avatar

2

None of the provided answers worked for me on macOS 11 Big Sur. The problem turned out to be that programs require special permission to access the Desktop, Documents, and Downloads folders, and Java breaks both the exception for directly opened files and the permission request popup.

Fixes:

  • Move the .jar into a folder that isn’t (and isn’t under) Documents, Desktop, or Downloads.
  • Manually grant the permission. Go to System Preferences → Security and Privacy → Privacy → Files and Folders → java, and check the appropriate folders.

answered Jan 27, 2021 at 9:50

twhb's user avatar

twhbtwhb

4,3142 gold badges20 silver badges23 bronze badges

If you are using OSX, downloaded files are tagged with a security flag that prevents unsigned applications from running.

to check this you can view extended attributes on the file

$ ls -l@
-rw-r--r--@ 1 dave  staff  17663235 13 Oct 11:08 server-0.28.2-java8.jar
com.apple.metadata:kMDItemWhereFroms         619
com.apple.quarantine          68

You can then clear the attributes with

xattr -c file.jar

answered Oct 13, 2017 at 10:24

nick fox's user avatar

nick foxnick fox

5708 silver badges15 bronze badges

1

I had a similar problem and I even tried running my CMD with administrator rights, but it did not solve the problem.

The basic thing is to make sure to change the Directory in cmd to the current directory where your jar file is.

Do the following steps:

  1. Copy jar file to Desktop.

  2. Run CMD

  3. Type command cd desktop

  4. Then type java -jar filename.jar

This should work.


Edit: From JDK-11 onwards ( JEP 330: Launch Single-File Source-Code Programs )

Since Java 11, java command line tool has been able to run a single-file source-code directly. e.g.

java filename.java

Gabor Dicso's user avatar

answered Dec 26, 2018 at 6:22

Vishwa Ratna's user avatar

Vishwa RatnaVishwa Ratna

5,5975 gold badges33 silver badges55 bronze badges

It can also happen if you don’t properly supply your list of parameters. Here’s what I was doing:

java -jar test@gmail.com testing_subject file.txt test_send_emails.jar

Instead of the correct version:

java -jar test_send_emails.jar test@gmail.com testing_subject file.txt

answered Jul 15, 2015 at 8:06

Buffalo's user avatar

BuffaloBuffalo

3,8618 gold badges44 silver badges69 bronze badges

This worked for me.

cd /path/to/the/jar/

java -jar ./Calculator.jar

answered Nov 15, 2016 at 18:18

Bastian Cáceres Pino's user avatar

For me it happens if you use native Polish chars in foldername that is in the PATH.
So maybe using untypical chars was the reason of the problem.

answered Oct 8, 2015 at 9:52

Huxwell's user avatar

HuxwellHuxwell

1712 silver badges14 bronze badges

sometime it happens when you try to (run or create) a .jar file under /libs folder by right click it in android studio. you can select the dropdown in top of android stuio and change it to app. This will work

enter image description here

answered Feb 17, 2016 at 10:44

anand krish's user avatar

anand krishanand krish

4,2974 gold badges44 silver badges47 bronze badges

My particular issue was caused because I was working with directories that involved symbolic links (shortcuts). Consequently, trying java -jar ../../myJar.jar didn’t work because I wasn’t where I thought I was.

Disregarding relative file paths fixed it right up.

answered Nov 18, 2015 at 23:31

MattSayar's user avatar

MattSayarMattSayar

2,0786 gold badges23 silver badges28 bronze badges

In my case the suggested file name to be used was jarFile*.jar in the command line. The file in the folder was jarFile-1.2.3.jar . So I renamed the file to jarFile. Then I used jarFile.jar instead of jarFile*.jar and then the problem got resolved

answered Jan 22, 2017 at 6:41

suku's user avatar

sukusuku

10.5k16 gold badges75 silver badges120 bronze badges

1

It can happen on a windows machine when you have spaces in the names of the folder. The solution would be to enter the path between » «.
For example:

java -jar c:\my folder\x.jar    --> 
java -jar "c:\my folder\x.jar"

Sundar's user avatar

Sundar

4,5906 gold badges36 silver badges61 bronze badges

answered Oct 31, 2017 at 8:57

assaf's user avatar

assafassaf

211 bronze badge

1

To avoid any permission issues, try to run it as administrator. This worked for me on Win10.

answered Mar 14, 2018 at 15:14

Gico's user avatar

GicoGico

1,2762 gold badges15 silver badges30 bronze badges

1

I know this thread is years ago and issue was fixed too. But I hope this would helps someone else in future since I’ve encountered some similar issues while I tried to install Oracle WebLogic 12c and Oracle OFR in which its installer is in .jar format. For mine case, it was either didn’t wrap the JDK directory in quotes or simply typo.

Run Command Prompt as administrator and execute the command in this format. Double check the sentence if there is typo.

"C:\Program Files\Java\jdk1.xxxxx\bin\java" -jar C:\Users\xxx\Downloads\xxx.jar

If it shows something like JRE 1.xxx is not a valid JDK Java Home, make sure the System variables for JAVA_HOME in Environment Variables is pointing to the correct JDK directory. JDK 1.8 or above is recommended (2018).

A useful thread here, you may refer it: Why its showing your JDK c:program files\java\jre7 is not a valid JDK while instaling weblogic server?

answered Oct 23, 2018 at 6:54

not_Prince's user avatar

not_Princenot_Prince

3203 silver badges17 bronze badges

For me it happen because i run it with default java version (7) and not with compiled java version (8) used to create this jar.

So i used:

%Java8_64%\bin\java -jar myjar.jar

Instead of java 7 version:

java -jar myjar.jar

answered Feb 9, 2020 at 19:19

Adir Dayan's user avatar

Adir DayanAdir Dayan

1,32813 silver badges21 bronze badges

I had a similar problem where TextMate or something replaced the double quotes with the unicode double quotes.

Changing my SELENIUM_SERVER_JAR from the unicode double quotes to regular double quotes and that solved my problem.

answered Mar 30, 2016 at 18:05

TankorSmash's user avatar

TankorSmashTankorSmash

12.2k6 gold badges68 silver badges106 bronze badges

this is because you are looking for the file in the wrong path
1. look for the path of the folder where you placed the file
2. change the directory cd in cmd use the right path

answered Jun 19, 2016 at 21:39

felipe's user avatar

0

I use NetBeans and had the same issue. After I ran build and clean project my program was executable. The Java documentation says that the build/clean command is for rebuilding the project from scratch basically and removing any past compiles. I hope this helps. Also, I’d read the documentation. Oracle has NetBeans and Java learning trails. Very helpful. Good luck!

answered Jul 16, 2017 at 13:43

user8315373's user avatar

Maybe you have specified the wrong version of your jar.

answered Sep 21, 2017 at 21:52

cosbor11's user avatar

cosbor11cosbor11

14.8k10 gold badges54 silver badges69 bronze badges

I finally pasted my jar file into the same folder as my JDK so I didn’t have to include the paths. I also had to open the command prompt as an admin.

  1. Right click Command Prompt and «Run as administrator»
  2. Navigate to the directory where you saved your jdk to
  3. In the command prompt type: java.exe -jar <jar file name>.jar

answered Jan 14, 2020 at 15:04

Michaela Burns's user avatar

Keep the file in same directory where you are extracting it. That worked for me.

answered Jan 22, 2020 at 2:18

Aishwary joshi's user avatar

Aishwary joshiAishwary joshi

711 gold badge1 silver badge4 bronze badges

This is permission issue, see if the directory is under your User.
That’s why is working in another folder!

answered Jul 31, 2020 at 13:05

Dimitrios's user avatar

DimitriosDimitrios

1,15311 silver badges10 bronze badges

Rename the jar file and try

Explanation :
yes, I know there are many answers still I want to add one point here which I faced.

I built the jar and I moved it into the server where I deploy (This is the normal process)
here the file name which I moved already existed in the server, here the file will override obviously right. In this case, I faced this issue.
maybe at the time of overriding there can be a permission copy issue.

Hope this will help someone.

answered Aug 3, 2020 at 14:12

Sainath Pabba's user avatar

If you are on WSL (Windows Subsystem for Linux), and following a guide which say, says this:

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

You actually need to specify the full path, even though you’ve provided it in the java.library.path part.

java -Djava.library.path=/mnt/c/dynamodb_local/DynamoDBLocal_lib -jar /mnt/c/dynamodb_local/DynamoDBLocal.jar -sharedDb

answered Apr 21, 2020 at 14:10

AncientSwordRage's user avatar

AncientSwordRageAncientSwordRage

7,13619 gold badges90 silver badges175 bronze badges

2

Have you tried to run it under administrator privoleges?
meaning, running the command in «Run As» and then select administrator with proper admin credentials

worked for me

answered May 14, 2019 at 20:28

Nick_Stubborn_Mex.'s user avatar

I was trying this:

After giving the file read, write, execute priviledges:

chmod 777 java-repl.jar

alias jr="java -jar $HOME/Dev/java-repl/java-repl.jar"

Unable to access bla bla…, this was on Mac OS though

So I tried this:

alias jr="cd $HOME/Dev/java-repl/ && java -jar java-repl.jar"

Litisqe Kumar's user avatar

answered Jul 23, 2019 at 8:53

Kinglee's user avatar

KingleeKinglee

531 silver badge8 bronze badges

Changing the default app for JAR files should fix this issue

by Matthew Adams

Matthew is a freelancer who has produced a variety of articles on various topics related to technology. His main focus is the Windows OS and all the things… read more


Updated on

  • The Unable to access the JAR file is a standard error when you don’t have compatible software to open it.
  • Some users reported that using stable file openers fixed the issue for them.
  • You can also fix this issue by uninstalling and downloading the latest version of Java.

unable to access jarfile

Java browser plug-ins might have gone out of fashion, but many programs run off Java. For example, you can open Java programs with JarFiles, among other software for opening JAR files.

However, some Java software users can’t always open JAR programs with the Unable to access JarFile error message popping up. This guide will show you some practical ways to get past this error message.

Why does it say unable to access jar?

The inability to access JarFile on Minecraft or Forge can be caused by mistakes on your path or issues with the software. Below are some of the prevalent causes:

  • Outdated Java version: If your Java version is obsolete, you cannot access JarFile using the docker container. You need to update Java to the latest version.
  • Wrong default program: Sometimes, this issue might be because you have not set the default program to open the JarFiles. Choosing Java as the default app for opening JAR files should fix this.
  • Issues with the JAR file path: If the path to your jar file is incorrect, you can get this error. The solution here is to ensure the path is correct.

How can I fix the unable to access JarFile error?

Before proceeding to the fixes in this guide, try the preliminary troubleshooting steps below:

  • Add .jar extension to the JAR file name
  • Beware of spaces in the JAR file path
  • Add quotes to the JAR file path if it contains space
  • Move the JAR file to another folder
  • Use a file opener software

If the fixes above fail to solve the issue, you can now move to the fixes below:

1. Update your Java version

  1. Press the Windows key + R, type appwiz.cpl, and click OK.
    appwiz unable to access jarfile
  2. Right-click the Java app and select the Uninstall option.
    uninstall
  3. Now, go to the official website to download the latest version of the Java app.

A broken or outdated app can cause the unable to access the JarFile issue. Downloading the latest version of the app should fix the problem.

2. Select Java as the default program for JarFiles

  1. Open File Explorer and the folder that includes your JAR file.
  2. Right-click the file and select Open with, and then Choose another app.
    choose another
  3. Select Java if it’s listed among the default programs.
  4. If Java isn’t listed among the programs, select the Look for another app on this PC option.
    look for unable to access jarfile
  5. Then browse to the Java bin folder, select  Java and press the Open button.

JAR file error messages usually pop up when Java isn’t configured as the default software for a JAR file. This can be the cause of the unable to access JarFile.

Setting Java as the default program should fix the issue here.

Read more about this topic

  • Error Authenticating With Venmo: 6 Ways to Fix it
  • Fix: Internet Speed is Fast, but Video Calls are Slow
  • Windows Software Development Kit: Everything You Need to Know
  • Fix: MSI Afterburner Failed to Start Scanning

3. Open the Jarfix Software

  1. Click jarfix.exe on this webpage to save the software to a folder.
    jarfix download
  2. Now, open the folder and double-click the jarfix.exe option.
    open jarfix unable to access jarfile
  3. The tool will start and fix issues with your jar file extension.
    jarfix success

In some cases, the unable to access JarFile issue on IntelliJ can be because of problems with the file type associations. This Jarfix.exe software will help you fix this issue and restore normalcy on your PC.

Those are a few resolutions that might fix the unable to access JarFile error and kick-start your Java software. After that, you only need to follow the instructions carefully, and the issue should be resolved.

For further details on installing a JAR file in Windows 10, check our guide to make the process easy.

If you have any other questions, please leave them in the comments section below.

newsletter icon

If you have recently tried to open a JAR package file, only to receive the error, “unable to access Jarfile,” this simply means that your computer either doesn’t have the right software to open the file, or you have the wrong file path. Other common reasons for getting this error is if you have an outdated version of Java, your computer is infected with malware, or the default program for opening your JAR files isn’t set correctly. Before we jump into the solutions for this, let’s take a look at what JAR is.

Unable to access jarfile error message on Windows

Understanding JAR Package Files

Java Archive or JAR is a package file format based on ZIP architecture. It is used to group together multiple Java class files, their metadata, and any resources these files need to run into one single package. The purpose of doing this is to then distribute the grouped files as needed for the running of applications and programs. In order to run the executable file in a JAR package, you must have the latest Java Run-Time Environment installed.

Jarfile Examples.

If you are getting the error, “unable to access Jarfile” it means that you are encountering one of the following problems:

  • Your system has malware that is either preventing the Jarfile package to open.
  • The Jarfile package is corrupted from malware.
  • You do not have the latest Java Run-Time Environment installed.
  • The default program for accessing JAR files isn’t set.
  • The file path for the executable Jarfile package is incorrect.

The “unable to access Jarfile” error is quite a common one since there are many popular programs that use Java as their programming language. For instance, Netflix uses it along with Python for applications in its back-end, while Spotify uses it to stabilize data transfer, and Minecraft uses it for its launcher. Other popular programs and services that use Java include: Uber, Amazon, LinkedIn, Google, and Android OS.

1. Update Your Java to the Latest Version

The most likely reason that you are getting the, “unable to access Jarfile” error is due to an outdated version of Java. Unfortunately, outdated versions of Java Run-Time Environment are prone to security risks and loopholes, so keeping it updated is highly recommended regardless of whether you are getting the above error.

  1. In your computer’s search menu, type in “Control Panel”.
  2. In the control panel window, choose “uninstall a program” under programs.
Image of Windows 10 control panel and the uninstall a program option.
  1. In the list of programs, scroll until you see Java. Or use the search program box in the top right-hand corner of the window.
  2. Take a look at the version number and see if it matches the latest release.
  3. If it doesn’t, uninstall the program by right-clicking on it.
Image of how to uninstall Java and see the version number in the uninstall program function on Windows 10.
  1. Choose “yes” when prompted.
  2. From the official Java website, download the latest version.
  3. Once downloaded, use the setup wizard to install Java.

Now, re-try opening your JAR package to see if the problem is fixed.

2. Make Java the Default Program for Opening JAR Packages

If you are still getting the “unable to access Jarfile” error after updating your Java Run-Time Environment to the latest version, then you may not have Java set as the default program to use for opening JAR packages.

  1. In your computer’s taskbar, open File Explorer.
  2. Find the folder that contains your JAR package.
  3. Right-click on the folder and choose “open,” and then Java.
  4. If Java is not listed, select “choose another app”.
Use Java to open your Jarfile package.
  1. In the window that pops up, choose Java from the list. If it is not there, choose the “look for another app on this PC” option.
  2. Browse your computer for Java and find the program. Select it and hit the “open” option.
  3. A prompt window may open. If it does, choose “okay” and “open”.
  4. Double-click on your JAR package executable to open.

When browsing for Java on your computer in step 6, the most common place for it to be is in Program Files (x86)/Java/Java <Version>/Bin/Java.exe. Keep in mind that Java is usually installed to the default hard drive disk where your operating system is, unless you do a custom installation path. So, keep this in mind when trying to find Java on your computer.

3. Set Java as a Default Association Permanently

If you use a lot of programs or applications that use the Java Run-Time Environment, it is recommended that you set Java as a default association permanently in your computer, so that any JAR packages or files are automatically opened by Java.

  1. Press the Windows key and “I” on your keyboard to open Settings. Alternatively, type “settings” into your computer’s search menu.
  2. Click into the “apps” option in the Settings window.
Apps in Settings Window on Windows 10
  1. Choose “default apps” in the left-hand sidebar.
  2. Scroll until you see, “choose default apps by file type” and click it.
  3. Now, look for .jar in the list and click on “Choose a default” next to it.
  4. Find the Java Platform Program (Java Run-Time Environment) on your computer.
  5. Save the changes and exit.
Windows 10 Settings - Apps, Set Java as a Default Program to Use

Now restart your computer for the changes to take effect and see if you can open your JAR package without the, “unable to access Jarfile” error.

4. Check for Malware to Eliminate Infections Causing Trouble

If you are still getting the “unable to access Jarfile” error, it may be from malicious malware. A virus can easily exploit your registry and modify it to make JAR packages unusable. It is highly recommended that you run a thorough scan of your entire computer to look for malware. If you find some, remove it and uninstall Java. Repeat fix 1 in this list to reinstall.

5. Configure Hidden Files/Folders/Drives to Show

While not as common, sometimes hidden files, folders, and drives can cause the “unable to access Jarfile” error.

  1. In your computer’s taskbar, open File Explorer.
  2. At the top of the window, click on the “View tab”.
Click View - Then Options.
  1. Now click on the “Options” button to the far right.
  2. In the new window that opens, click on the “View tab” again.
  3. In the list, choose the “Show hidden files, folders, and drives” option.
  4. Hit Apply and then hit OK.
Checkmark the Show Hidden Files, Folders, and Drives Option.

6. Repair Your Java Programs with Jarfix.

If you are using programs that launch with Java and they are not responding to you, no matter how many times you try to open the application, then it may be time to repair your JAR associations. To do this, simply download Jarfix, a lightweight program that fixes hijacked JAR associations, and run it.

What Jarfix looks like.

7. Check the Documentation If You Are a Developer

If you are working in Java as a developer and come across the “unable to access Jarfile” error, it is likely that there is a minor mistake within the coding. It is recommended that you go back through and re-read to make sure that you have the right file path and the correct parameters for the code to work. Depending on what utility you are using to open and run your JAR packages, you may need to go back through and re-read the documentation on how to get it functioning properly.

Wrapping It Up

In most cases, the “unable to access Jarfile ” error will be solved by updating your Java Run-Time Environment to the latest version, but if it doesn’t solve the problem, please do try out the other methods on this list. Let us know in the comments below if we were able to help you!

Unable to access jarfile is a common error in the latest version of Java programming language. In this article, the reader will be told about all the reasons behind this error and how they can use various procedures to remove this error. Let’s start with the causes of this error and then gradually move to all possible solutions of this error!Unable to Access Jarfile Error in Java Programming

Contents

  • Why Does the Unable to Access Jarfile Error Message Arises?
    • – Incorrect Path
    • – Typo in the File Name/ Syntax Errors
    • – Permissions Issue
    • – The JAR File Is Corrupted
    • – Missing Dependencies
    • – Default Program Causing Issues
    • – Hidden Files Causing Issues
    • – Minecraft Server Causing Issues
  • How To Resolve the Unable to Access Jarfile Error Message?
    • – Check the File Path
    • – Check the File Name
    • – Jar File Should Be in the Same Directory as the Command Line Script
    • – Check if the Jar File Is Corrupted
    • – Check if Java Is Installed
  • Conclusion

Why Does the Unable to Access Jarfile Error Message Arises?

The unable to access jarfile error message arises because the Java Virtual Machine (JVM) is unable to access or read a jar file specified in a command-line script or application. This error may be caused by issues such as incorrect file paths, corrupted jar files, or problems with command-line syntax.

Some other reasons are explained and listed below:

  • Typo in the file name.
  • Permissions issue.
  • Missing dependencies.

– Incorrect Path

The incorrect path error message can occur when the path to the JAR file is not specified correctly. When a Java application is executed from the command line, the operating system needs to know the exact location of the JAR file to run the application correctly.

The path is a series of directories that lead to the location of the JAR file. An incorrect path to the JAR file can result in the unable to access jarfile error message.

– Typo in the File Name/ Syntax Errors

Another reason why this error message can occur is when there is a mistake in the spelling of the JAR file name or any other type of syntax error. The operating system uses the filename to locate and execute the JAR file, so any errors in the filename can result in the unable to access jarfile error message.

It is essential to double-check the spelling of the JAR file name, including the case of the letters. For example, if the JAR file is named “myJarFile.jar,” but you accidentally type “myjarfile.jar” or “myJarfile.jar,” the operating system will not be able to find the file and execute it.

  • Error unable to access jarfile /app.jar kubernetes.
  • Error unable to access jarfile server jar minehut.
  • Error: unable to access jarfile agent.jar jenkins.
  • Java virtual machine launcher error: unable to access jarfile.
  • Error from tabula-java: error: unable to access jarfile.

– Permissions Issue

The permissions issue error message can occur when the Java application does not have sufficient permissions to access or execute the JAR file.

In most operating systems, files have permissions determining who can read, write, and execute them. If you run the Java application and it does not have the appropriate permissions to access the JAR file, the “unable to access jarfile” error message will appear.

– The JAR File Is Corrupted

Another cause of the error can be when the JAR file is corrupted. This error message can occur when the JAR file itself is damaged or incomplete. When a JAR file is corrupted, it means that some parts of the file are missing or the file is not in the expected format.

The unable to access jarfile error message is one indication that the JAR file may be corrupted. Other symptoms may include unexpected behavior or error messages when running the Java application.

– Missing Dependencies

The missing dependencies error message can occur when a Java application requires one or more external libraries or dependencies to run correctly, but they are not present in the system. A dependency is a piece of code or software that is required by another program to function correctly.Reasons of Unable to Access Jarfile Error Message

Java applications often use external libraries or dependencies to provide additional functionality or access to specific resources. When a Java application is executed, it checks for the presence of these dependencies in the system, and if they are missing, it can result in the unable to access jarfile error message.

– Default Program Causing Issues

Sometimes, the default program or default file causes the error to arise. This error message is related to Java and the Java Virtual Machine (JVM) and occurs when the JVM is unable to read or open jar file specified in a command-line script or application. The error message usually appears in the command prompt or terminal window when the program is executed.

– Hidden Files Causing Issues

Hidden files may be relevant in the context of resolving the “Unable to access jarfile” error message if the jar file or any of the directories in the file path are hidden. Hidden files or directories are files or directories that are not displayed by default in the file explorer or command-line interface and are often used to store configuration or system files.

If any of the directories in the file path to the jar file are hidden, the JVM may not be able to find the file and resulting in the error message. To check for any hidden directories in the file path, you can use the “dir” command in the command prompt or terminal, with the “/a” parameter to show hidden files and directories: dir /a. If any of the directories in the file path are hidden, you may need to unhide them using the file explorer or the “attrib” command in the command prompt or terminal: attrib -h path\to\directory.

– Minecraft Server Causing Issues

The Minecraft server is not directly related to the “Unable to access jarfile” error message discussed in this article. However, the error message may occur when trying to run a Minecraft server if the server’s configuration or startup script references a jar file that the JVM is unable to access or read.

When setting up a Minecraft server, the server’s configuration or startup script typically specifies the location of the Minecraft server’s jar file. If the jar file is not located in the specified location, or if the file path contains errors, the JVM may not be able to access the file and result in the unable to access jarfile error message.

How To Resolve the Unable to Access Jarfile Error Message?

To resolve the unable to access jarfile error, users can check the file path and name, ensure that the jar file is in the same directory as the command line script, and verify that the jar file is not corrupted.

– Check the File Path

When we say “Check the file path” in the context of resolving the unable to access jarfile error message, we mean verifying that the path to the jar file is correct.

The path is a series of directories that lead to the file. If the path is incorrect, the JVM (Java Virtual Machine) will not be able to locate the jar file which will result in the error message.

To check the file path, you need to ensure that the path you are specifying in the command line is correct. You should verify that the directory structure is accurate and that each directory in the path exists. You should also make sure that the path separator character used in the command line matches the one used by your operating system.

For example, if your jar file is located in the “myproject” directory, which is located in the “Documents” directory on your computer, the file path would be:

C:\Users\yourusername\Documents\myproject\myfile.jar

It is important to ensure that the file path is spelt correctly and that you are using the correct case for any directories or filenames. If you are unsure of the correct file path, you can use the “cd” command in the command prompt to navigate to the directory where the jar file is located and then use the “dir” command to see the contents of the directory.

By verifying that the file path is correct, you can eliminate one potential cause of the unable to access jarfile error messages and increase the chances of successfully running your Java program.

– Check the File Name

“Check the file name” in the context of resolving the “Unable to access jarfile” error message; we mean verifying that the jar file name is spelt correctly and that it has the correct file extension.

The jar file name should be spelt exactly as it appears on your computer, including any uppercase or lowercase letters. If there is a typo in the file name, the JVM (Java Virtual Machine) will not be able to find the file which will result in the error message.Resolve the Unable to Access Jarfile Error Message

In addition, the file extension of the jar file should be “.jar”. If the file extension is incorrect, the JVM will not recognize the file as a jar file and will result in an error message.

To check the file name, you should navigate to the directory where the jar file is located and check the spelling of the file name and its file extension. If you are unsure of the correct file name or file extension, you can use the “dir” command in the command prompt to see a list of files in the directory.

– Jar File Should Be in the Same Directory as the Command Line Script

When you try to run a jar file from the command line, you need to specify the file path to the jar file. If the jar file is not located in the same directory as the script that is trying to run it, you need to specify the full path to the file.

To check if the jar file is in the same directory as the command line script, you should navigate to the directory where the script is located and verify that the jar file is also located in that directory. If the jar file is not located in the same directory, you should move the file to the correct directory or specify the full path to the file in the command line.

– Check if the Jar File Is Corrupted

If the jar files are damaged or corrupted, the JVM (Java Virtual Machine) may not be able to read the file, resulting in the error message.

To check if the jar file is corrupted, you should try to open the file in file archiving software, such as WinZip or 7-Zip, and verify that the contents of the file are intact. If the file is damaged or corrupted, you may need to download the file again from a reliable source or retrieve a backup copy of the file.

– Check if Java Is Installed

Ensure that Java is installed on your system and that the JAVA_HOME environment variable is set. If Java is not installed or the environment variable is not set, the JVM will not be able to run the jar file.

Conclusion

After reading this article, the reader can now resolve this error message on their own with a proper understanding of this error message. Some key takeaways from the article that will help you fix this error are:

  • This error message is a common issue in the latest Java version that occurs when the Java Virtual Machine is unable to access or read a specified jar file.
  • This error can be caused by a variety of issues, such as incorrect file paths, corrupted files, or problems with command-line syntax.
  • By checking the file path and name, ensuring the jar file is not corrupted, and checking for hidden files or directories, you can resolve this error.
  • Additionally, you may need to troubleshoot your Java environment or adjust your command-line syntax to run your program successfully.

Remember, it is much easier to fix an error once you know its cause!

  • Author
  • Recent Posts

Position is Everything

Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL. Meet The Team

Position is Everything

Понравилась статья? Поделить с друзьями:
  • Java ошибка 1603 как исправить windows 10
  • Java ошибка integer parseint
  • Java не скачивается ошибка 1603
  • Java ошибка 2203
  • Java логирование ошибок