• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java code for giving write permission to group(775)

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I dont know if it is the correct place to post my query. If any one has any idea kindly revret asap. My java application creates a folder with 755 permission when file.mkdir() is used. According to the requirement, group needs to have write permission as well i,e it should be 775 for the folder created. Is there any way in java 1.5 or 1.6 to do so i.e to provide write permission to group. If any one has any idea kindly let me know....my email id : [ deleted e-mail address ]
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Java 6 did add the capability to set write permissions, but I don't think you can set it at a group level.... so your best option is probably runtime.exec(chmod).


BTW, this topic is not related to threads. Moving to the general forum.

Henry
 
sup rty
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry, thank you for the reply...i also have been searching for a solution for the bug...found a few.....but as you mentioned about the exec command...if i try out something like this:
Process p = Runtime.getRuntime().exec("chmod 775" ," path of my file");....will it work....thanks in advance
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseTheForumNotEmail.

I deleted your e-mail address from your post. Note that posting your e-mail address in a public forum is not a good idea - did you know that there are hackers on the web that search the Internet for e-mail addresses, and then use those e-mail addresses to send junk e-mail to? That's how they get your address and why you receive junk mail.
 
sup rty
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Jesper...thanks for the info...was new to the forum so didnt know...will keep in mind about not posting my emailid in the forum.
@ henry....i understood the way you mentioned above ....but will p = Runtime.getRuntime().exec("chmod", commands ,f); where chmod is the unix command, commands is an array striing and f is the file ....will it work in window system...as i am passing a unix command...is it possible to execute a unix command in the exec() function in windows OS...Kindly revert asap and also if you know any other way or any other API which can do the task for me...kindly let me know about it...thanks
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Windows has a totally different permission model, so no, chmod will not work.
 
sup rty
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob...thank you for the information , so could you suggest any solution by which it could be done ....that is giving 775 permission to group using java ...thanks
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

supratimC chakraborty wrote:Hi Rob...thank you for the information , so could you suggest any solution by which it could be done ....that is giving 775 permission to group using java ...thanks




That is the whole point. In Windows, there is no concept of 775. Permissions are given on a user by user basis -- there is no concept of setting up a group (there is, with vista, but there is no concept of the group for the file). How can you do something that just isn't possible?


To further elaborate, with Vista, there is an owner for the file. And this owner can give read and / or write permission on a user by user basis. There is also a concept of groups, which can also be given access on a group by group basis. With this concept, it is possible for users (or users in groups), who are not owners, to have individual (or group) permissions for the file. This is different from unix, where a file belongs to a single user and group, and permissions are given out as such.

I haven't played much with this new feature, so you'll have to try it out, or wait til someone else explains it better to you.

Henry
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This behaviour is not new to Window Vista. It has been part of Windows 2000 and beyond, although sometimes it was hidden.

Any file or folder has an owner; this can be a user or a group. Users and groups can both be either local or part of domain. Furthermore, additional rights can be set up for each user or group specifically. For instance. user Rob can get read and modify rights whereas group Users gets only read rights. As Henry said, any user or group can get any rights.
 
sup rty
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks rob and henry...seems like my issue might not be solved using normal java coding....just to give a brief description of my application....i have a daemon process which basically takes input from the database and copies files from one location to another and when it does so , there is a folder created using java file.mkdir() function and when it is done it gives 755 permission by default. there is a requirement to make it 775, so that group also could write....according to both of you there mite not be a standard procedure to do so using java...i would probably try finding out some solution...meantime if anyone gets to know about it...kindly reply...thanks
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

supratimC chakraborty wrote:seems like my issue might not be solved using normal java coding....just to give a brief description of my application....i have a daemon process which basically takes input from the database and copies files from one location to another and when it does so , there is a folder created using java file.mkdir() function and when it is done it gives 755 permission by default. there is a requirement to make it 775, so that group also could write....according to both of you there mite not be a standard procedure to do so using java.



I'm totally missing the point of the problem.... You have a system that creates a file with the wrong permissions in Unix. You want a solution that fixes it, but the solution that we suggested only works in Unix, where is the only place that you have a problem (or could have this problem). Hence, you are rejecting the solution, because the problem doesn't exist in Windows?

Henry
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

supratimC chakraborty wrote: and when it is done it gives 755 permission by default. there is a requirement to make it 775, so that group also could write.



And BTW, you can also easily fix this by setting the umask in your .profile for the user running the program. Or in the script that starts the java program, if you don't want to make it user-wide.

Henry
 
sup rty
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi henry,

so if i add umask 022 for my folder in the /etc/profile....it should created the folder with 775 permissions?
 
reply
    Bookmark Topic Watch Topic
  • New Topic