Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Output commands to the System

Posted on 2003-02-21
6
Medium Priority
?
174 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

571 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