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.
From the Start menu, type cmd in the textbox and when the program cmd.exe appears, right click on it and select Run as Administrator. Now when ytou execute java -jar itwill run with Admin rights.
Right-click the file and select Open With. In the Open With window, click the Browse button to open the File Explorer window. You need to find the Java executable file (java.exe file) on your computer hard drive.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With