-1

I want to fetch all groups available on Linux machine using Java. Can someone tell me which Java API I can use?

ekad
  • 14,436
  • 26
  • 44
  • 46
Shashi
  • 2,686
  • 7
  • 35
  • 67

1 Answers1

0

If you are willing to give up on the portability of your app(Linux only instead of cross platform deployment) you could do a system call, where you combine the calling of a command line function with the groups command

Community
  • 1
  • 1
Cakes
  • 108
  • 7
  • is there any direct way for pulling all groups instead of calling command ? – Shashi Sep 22 '16 at 08:57
  • I think not, but I could be mistaken, as I understand it, java compiles to javacode and that runs on a java virtual machine on your linux machine. That JVM interprets the javacode to machine instructions, since your java code can also run on windows,where there might not be groups, a "getgroups" function isn't available inside the javacode,java itself and thus not in the java virtual machine(since it would never be called) . – Cakes Sep 22 '16 at 12:28