10h02
10h02

Reputation: 35

File exists but java file.exists() but return false

As the title says, I'm checking if a file exists or not with java. The file is stored in

C:\Windows\System32.

If I run the project with Netbeans, no problem. It returns true.

But if I run the .jar, it returns false. I'm admin of the computer, but I don't know which privilege I have when I run the .jar.

Do you have any idea

Upvotes: 0

Views: 1031

Answers (3)

Binkan Salaryman
Binkan Salaryman

Reputation: 3048

According to this Oracle tutorial, you should check also Files.notExists - if it returns false, too, your program failed to verify the existence of the file.

Upvotes: 3

MeherHedhli
MeherHedhli

Reputation: 43

Maybe you have to run CMD as an administrator and then run your .jar file, like you didn't post the code we can't get a good idea about your issue.

Upvotes: 0

pepan
pepan

Reputation: 727

Try to run cmd.exe as an admin and then run your .jar from this cmd. Being an admin does not mean you are starting your apps with admin privilege.

Upvotes: 3

Related Questions