Home > Archive > Java Help > August 2005 > redirect to .cmd page
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
redirect to .cmd page
|
|
| bherbst65@hotmail.com 2005-08-09, 10:01 pm |
| Hi All,
I have win2K with NT.
If I have a java program, write instructions to do a runtime exe of the
"C:\WINNT\system32\CMD.EXE"
and then run as appearing inside the black dos page.
This is not homework,
Bob
| |
| bherbst65@hotmail.com 2005-08-20, 7:00 pm |
| For the record,
here is my solution gained by questioning persons at EE in the Q/A
areas of MS DOS and Java programming.
import javax.swing.*;
public class Runtimetest {
public static void main(String[] args) {
// Set the look and feel.
Runtimetest Runtimetest1 = new Runtimetest();
try {
UIManager.setLookAndFeel(
UIManager. getCrossPlatformLookAndFeelClassName());
}
catch (Exception e) {}
}
public Runtimetest (){
try{
/* Method 1:
* puts the X.class output in this IDE console
* the location of C:\Documents and
Settings\Delphi3\Desktop\DrJavaProjects
* and without the statements below of Runtime rt =....
*
* X.main(null);
*
* Method 2
* a notepad entry has only one line >>> java X then saved as
RunXwithCMD.cmd or as
* RunXwithCMD.bat
* placing RunXwithCMD.bat, in C folder, the X.class also in C
folder it will call it from C
* by a click on the RunXwithCMD.bat
* OR running THIS program here and the X.class
* in the folder C:\Documents and
Settings\Delphi3\Desktop\DrJavaProjects
* as shown below will open the DOS page and run the X.class
*
*/
Runtime rt = Runtime.getRuntime();
rt.exec(new String[]
{"cmd.exe","/c","start","c:/RunXwithCMD.bat"});
/* Method 3
* the X.class output is in the DOS console but the user has to
follow instuctions in the
* caption bar, of entering the additional words and then
pressing return
*
* Runtime rt = Runtime.getRuntime();
* rt.exec(new String[] {"cmd.exe", "/c", "start", "to Run the X
program, ENTER java X after the >"});
*/
}
catch (Exception e) {System.out.println("ERR");}
}
}
|
|
|
|
|