wood burning stoves 2.0*
The moose likes Java in General and the fly likes Running Java Program as a specific user. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running Java Program as a specific user." Watch "Running Java Program as a specific user." New topic

Running Java Program as a specific user.

Hasnain Javed Khan
Ranch Hand

Joined: Nov 23, 2007
Posts: 73
Hello all,

I have to run a utility on Ubuntu but that utility can be run only under a specific user group.I am using the ProcessBuilder class to run that utility but I don't know how to run the Java program (or the thread) under that specific user

Example: the utility dbmaint (Pervasive SQL) can be run only if you are under the user group "psql".

I would like to run dbmaint from my java program as a psql user. Any pointers code snippets would be really helpful

Thanks in advance.

Kind Regards.
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

Obviously there's nothing in the Java classes for that. So:

  • Figure out how to run the program as a specific user in your preferred shell
  • Run that shell command via ProcessBuilder
    I agree. Here's the link: http://aspose.com/file-tools
    subject: Running Java Program as a specific user.
    Similar Threads
    Run commands in a Java class
    Calling a psql command from a Groovy script
    running external program from Java
    Launching an .exe as a different user
    Capture Currently running application and share with a remote host