-2

I am developing an application in java using the classes form the package nio.

I would like to know how to provide the program the rights to write everywhere on the hard drive.

because it works on my home directory but not everywhere on the hard drive.

william.eyidi
  • 2,315
  • 4
  • 27
  • 39
  • 1
    Ever though It's not given full rights for a reason? Especially if you are going to be giving this out to companies/etc (other than that, I suppose you could allow access **only** if they have admin privileges already)? – jbutler483 Sep 02 '14 at 14:03
  • 2
    This will be determined by the access rights of whoever runs your application. How you control that is an OS-dependent issue (and not on-topic for Stack Overflow). – Duncan Jones Sep 02 '14 at 14:04
  • 1
    possible duplicate of [How do i programmatically change file permissions?](http://stackoverflow.com/questions/664432/how-do-i-programmatically-change-file-permissions) – DavidPostill Sep 02 '14 at 14:08
  • 2
    As long as you don't access that **one folder** that I don't... uhh.. have :O – RossC Sep 02 '14 at 14:27

1 Answers1

3

The permission is not associated with your program but with who (which account) runs this program, if it's being executed by a system account with administrator privileges then the program will have the power to perform I/O operations everywhere.

In linux you can grant 'sudo' access to non-root users, you can check if that would be an option for you, however, it seems like a risky scenario, you might want to study this use case and consider specifying the exact permissions you need based on your needs

If you are not sure who's running this program, you can verify the java process:

  1. Search for a java.exe in your Windows environment (http://technet.microsoft.com/en-ie/sysinternals/bb896653.aspx)
  2. Run ps fuxa | grep java in you linux terminal
the_marcelo_r
  • 1,847
  • 22
  • 35