'Run commands that require root access from IntelliJ Java project

I am working on a Java project together with other developers, all using macOS. As a part of its functionality, the code in this project needs to edit local /etc/hosts file which requires root user access. To accomplish that, we all run the IDE (IntelliJ) as root which creates a bunch of inconveniences.

I am really keen to find another solution to this problem. I had an idea to maybe somehow use a local environment variable (perhaps managed in IDE profile or something) but I am not sure how to do that.

Any ideas\suggestions how I can solve this problem?



Solution 1:[1]

Hope u have got the solution, But this answer might help others. Starting interllij using command sudo ./idea.sh will fix this issue. After staring the IDE use su - <current user> to switch back to the current user.

Note : u have to give the root user privilages to the current user. for that follow this link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dijo francis