Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opening jar file with admin privilege

Tags:

java

jar

admin

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.

like image 589
Suhail Gupta Avatar asked May 24 '11 10:05

Suhail Gupta


People also ask

How do you run a java program as administrator?

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.

How do I open an executive JAR file?

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.


1 Answers

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.

like image 88
Rup Avatar answered Sep 21 '22 12:09

Rup