Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

redirect to .cmd page

Thread view: 
bherbst65@hotmail.com - 10 Aug 2005 02:42 GMT
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 - 20 Aug 2005 14:46 GMT
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");}
 }
}


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.