Suhail Gupta
Suhail Gupta

Reputation: 23276

opening jar file with admin privilege

I am getting this exception when i open jar file using cmd: java.io.FileNotFoundException: C:\Windows\System32\drivers\etc\hosts.File (Access is denied) How can i open jar file with administrator privilege? Simply double clicking the jar file does not open the jar file.I am using win7 as OS.

Upvotes: 15

Views: 59917

Answers (2)

Ashium
Ashium

Reputation: 496

If you want to run jar file with admin privileges from console or by double clicking, without explicitly executing it with admin rights Which is most obvious from user's point of view as he might just know how to click and not internal working. Then this is my post answering your quest in simple steps. Run Java file as Administrator with full privileges

Upvotes: 0

Rup
Rup

Reputation: 34418

If I understand correctly, you're trying to run java from a command prompt but want admin privileges. In that case, right-click on the "command prompt" and choose "run as administrator", then you can

java -jar myprogram.jar

from the command prompt as before.

However do you really want to allow this program to edit your hosts file? I'd recommend you find out what it's trying to do and make the change manually if you're happy with it.

Upvotes: 41

Related Questions