LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 03-02-2004, 08:23 AM   #1
u4u
LQ Newbie
 
Registered: Aug 2003
Location: Pune (india)
Posts: 15

Rep: Reputation: 0
how to run shell command in java?


i want to run the shell command in java.Also help me how to run executable files of linux environment in java. As in "c" language we use "system" command to run shell command and executable file. How can i achieve it in Java???
 
Old 03-02-2004, 08:34 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,791
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
Um, why would you want to since it pretty much defeats the purpose of writing a program in Java? Is there really no Java based way to do what you want?
 
Old 03-02-2004, 10:06 AM   #3
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 425
Blog Entries: 1

Rep: Reputation: 36
you can use exec command.

Process processName=r1.exec("command");
processName.waitFor();

//sorry I clicked submit by accident

Last edited by aizkorri; 03-02-2004 at 10:09 AM.
 
Old 03-02-2004, 10:08 AM   #4
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 425
Blog Entries: 1

Rep: Reputation: 36
I don't remember what you have to import but the command is "exec":

e.g:

Runtime r=Runtime.getRuntime();
Process processName=r.exec("command");
processName.waitFor();//if you want to wait for it
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run a command through a Java program kernelvn Programming 3 12-02-2004 10:25 PM
Creating a shell script to run Java program paultaylor Programming 7 11-12-2004 04:11 PM
run shell command inside of c code? khucinx Programming 2 05-17-2004 11:04 AM
How to run a shell command containing awk, and grep within a C program Linh Programming 3 06-05-2003 08:05 PM
shell problems ? cant run Java commands RedHat123 Linux - General 2 07-16-2002 11:29 PM


All times are GMT -5. The time now is 01:21 AM.

Main Menu
Advertisement
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