LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 07: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, 07:34 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
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, 09:06 AM   #3
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 434
Blog Entries: 1

Rep: Reputation: 55
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 09:09 AM.
 
Old 03-02-2004, 09:08 AM   #4
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 434
Blog Entries: 1

Rep: Reputation: 55
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



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 09:25 PM
Creating a shell script to run Java program paultaylor Programming 7 11-12-2004 03:11 PM
run shell command inside of c code? khucinx Programming 2 05-17-2004 10:04 AM
How to run a shell command containing awk, and grep within a C program Linh Programming 3 06-05-2003 07:05 PM
shell problems ? cant run Java commands RedHat123 Linux - General 2 07-16-2002 10:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:48 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
Open Source Consulting | Domain Registration