opening jar file with admin privilege

Suhail Gupta picture Suhail Gupta · May 24, 2011 · Viewed 56.3k times · Source

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.

Answer

Rup picture Rup · May 24, 2011

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.