Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running Java Program as a specific user.

 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Hasnain.
 
Paul Clapham
Sheriff
Posts: 21319
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic