Sorry I didn't clearly mention that I am working with windows, so the solutions related to linux Is there any way to execute a process through another user using java (by giving username and password in the code)?
Currently I am using process p = Runtime.getRuntime().exec("cmd")
but I need to run this as a different user. Is there any function that supports this? or any other approach in java?
Edited: Sorry I didn't mention it previously that I am working on windows. So the solutions related to linux os are not applicable.