LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-10-2004, 07:10 AM   #1
ranger225
LQ Newbie
 
Registered: Aug 2004
Posts: 29

Rep: Reputation: 15
Question how to run linux command from java program?


hi friendz,
i wrote a java program in which is creating a file using the "File" class.... but after creating it i want to change the permissions of tht file.......i.e. i want to run "chmod" command from java.... does any pone know how to do it? or is there any other way to do it using File class or some other class?.....

bye....
 
Old 11-10-2004, 07:55 AM   #2
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 425
Blog Entries: 1

Rep: Reputation: 36
you can do it like:

Runtime r =Runtime.getRuntime();
Process changePermissions=r.exec("chmod whatever pathToWhateverFile");
changePermissions.waitFor();

hope this helps
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compile and run a java program in linux !!!! jmax24 Programming 7 08-06-2010 04:56 AM
Execute a linux command using a java program tvalenzuela Programming 2 10-07-2005 12:59 PM
How to run a command through a Java program kernelvn Programming 3 12-02-2004 10:25 PM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 09:19 AM
C program code to run a Linux command line Linh Programming 10 06-11-2003 02:59 PM


All times are GMT -5. The time now is 02:09 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration