• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set windows explorer option from java ?

 
desi sur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to open a folder in file server we normally use following command in java

Runtime.getRuntime().exec("explorer " + dirPath) which will open a windows explorer option.

However is there a way to remove/disable options like rename,add folder other functions in the windows explorer from java ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way to do this in Windows explorer, so I'd guess you can't do it from Java.

What you need sounds like properly defines file permissions, ratyher than restricted behaviour of one application. Why no run your Java application as a user who only has read permissions?
 
desi sur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply, but how do we set file permission dynamically from java program.

for instance we have below direcotry structure and want to give write access to place or edit files under LEVEL 2 DIRECTORIES , how can we do that ? I also donot want him to navigate uppel level directories. How do we set permissions from java ?

LEVEL 1 DIR
LEVEL 2 DIR
LEVEL 2 DIR
FILE1
FILE2
FILE3
LEVEL 2 DIR
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have access to file permissions with the java.io.FilePermissions class.

However, think about what you are trying to do here: you have a program running on a user's machine, presumably as that user? And you want to selectively restrict access to their own file system? OK you can do it, but its trivial to subvert. Why don't you want to allow users to navigate to certain places in their own file system?
 
desi sur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, thanks for your reply.

However in this particular case it is a file share and there are other directories which cannot be shared to user, so each one should be restricted to just creating a directory and copying there files into that directory (level2).

Is there any sample code to set file permission using FilePermission ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!