?
Solved

Output commands to the System

Posted on 2003-02-21
6
Medium Priority
?
169 Views
Last Modified: 2010-03-31
Hi, i'm just starting out with java,

            Is there a way to output commands to the Terminal window (for UNIX) or to MSDOS prompt (for using windows) from within a java program ?
i talking about commands like :
"cd Java/Programs"
or
"javac HelloWorld.java"
0
Comment
Question by:4mod3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 200 total points
ID: 7995481
for unix:

Runtime.getRuntime().exec("cd Java/Programs");

for windows:

something more like this (if it's a system command)
String[] cmd = new String[3];
cmd[0] = "command.com";
cmd[1] = "/C";
cmd[2] = "cd Java/Programs";

Runtime r = Runtime.getRuntime().exec(cmd);

// note, on win 2k/xp/nt cmd[0] should be "cmd.com"
0
 

Author Comment

by:4mod3
ID: 7995518
thanks for that bobbit
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7996791
> thanks for that bobbit
no problem, but why the 'B'?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 1

Expert Comment

by:Computer101
ID: 7999101
A request has been made to change the grade,  The expert feels the current grade does not fit the criteria of the intended guidelines.  Those guidelines are below.  If no response, I will review this question and grade accordingly..

Computer101
E-E Admin

How Do I Know What Grade to Give?
Although we use an A-D scale here at Experts Exchange, it works differently than, say, school grades. If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade, since they have taken the time to provide you with a working solution. If a possible solution is incomplete - ask for clarification or details before accepting the answer and grading it. People should not be given lower grades because of incorrect grammar or because you just accepted their answer or comment to close the question. Keep in mind, your question and any follow-up comments should be focused so that there can be a specific answer. The following is a good guideline to follow when grading:

A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.

B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.

C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.

Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support.
0
 

Author Comment

by:4mod3
ID: 8001783
sorry i was unaware of grading guidelines, ill try change it
0
 
LVL 1

Expert Comment

by:Computer101
ID: 8001795
I have done it

Computer101
E-E Admin
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question