• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create Directory through Java

 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,

So I am struggling through Linux issue and was hoping I might get some help. Currently I am trying to create a directory, which will be used to right files to. I don't actually create this directory till the first file is created. The code to create this directory is:

File dir = new file(/var/log/newFile);
dir.mkdirs();

The first is it keeps telling me I don't have permission to write the file, is there a way to override this?

The Second when I create the file manually I cant write to it... this should be taken care of with

dir.canWrite()... Correct?


Thanks,
Jonathan Larkin
 
Paul Clapham
Sheriff
Pie
Posts: 20971
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have permission to create that directory? Then sure, there's a way to deal with that. But not through Java, of course. You just execute a suitable Unix command which grants you that permission, or you get somebody with enough permissions to run that command.
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay I guess ill stuff it in the RPM spec file then, that seems to get run as root!

Thanks!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Lark wrote:Okay I guess ill stuff it in the RPM spec file then, that seems to get run as root!

Thanks!


You can scratch the "seems to". RPMs installed as production OS components MUST be installed using root privileges - if for no other reason that the RPM database is not updatable by non-root users and until the database is updated, the package isn't officially "installed".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic