Running java with root.
Answered
in order for me to run my program properlly with usb4java i need to run the project with root. How do i make sure that the run command runs with root and to ensure the jar run as root...
Please sign in to leave a comment.
There is no way to do it directly in IntelliJ IDEA.
You will need to make a shell script to run java with sudo and pass the arguments to the normal java executables. Make a copy of the JDK installation where java executable is replaced with this script and the original executable is renamed to some other name and is called from this script. Then add this new JDK in IntelliJ IDEA and use it to run your project.
The script should not ask for password (https://askubuntu.com/a/556698/9280).
You can find the step by step guide for Python here: https://esmithy.net/2015/05/05/rundebug-as-root-in-pycharm/. It's easy to make the same with Java. Note that you need to replace the original `java` executable with your shell script and call it by a different name, unlike Python where you specify the shell script directly, for Java IntelliJ IDEA will always run java command in the JDK installation.