aluthgrp
February 6th, 2001, 01:28 AM
Hi guys,
Could u pls tell me how to run a dos cmd using java.
rgds
ruwan
Could u pls tell me how to run a dos cmd using java.
rgds
ruwan
|
Click to See Complete Forum and Search --> : executing dos commands aluthgrp February 6th, 2001, 01:28 AM Hi guys, Could u pls tell me how to run a dos cmd using java. rgds ruwan Geert Arys February 6th, 2001, 03:18 AM Hi Ruwan, In Runtime, you have some exec() methods you can use for this. The most simple one is: Runtime.getRuntime().exec("notepad.exe"); However, if you want to run true DOS commands (copy, dir, ...), you'll have to call the shell like this: Runtime.getRuntime().exec(% brokenwing April 1st, 2001, 11:52 AM I wanna open a .html file by calling browser in a java program! Can I make it? this is broken wing! Norm April 1st, 2001, 01:47 PM There was an answer to this recently. You don't say what OS you are on. On Win9x this works: Process p = Runtime.getRuntime().exec("START xxxxx.html"); Norm eugene wong February 26th, 2002, 08:41 PM what abt for Win NT? thanks! Norm February 27th, 2002, 08:39 AM If you have Win NT try it and let us know! Norm eugene wong February 27th, 2002, 08:03 PM hmmm.... windows NT doesn't seem to support the "START xxxx.html" command, even if it does work from DOS command prompt. what i managed to find is this shortcut command that could work from the Runtime method: "rundll32 url.dll,FileProtocolHandler xxxxx.html" which works fine with my WinNT terminal. this is the link where i found this tip: http://www.javaworld.com/javaworld/javatips/jw-javatip66.html bejenariu February 28th, 2002, 04:58 AM Try this: import java.applet.*; import java.awt.*; import java.awt.event.*; import java.net.*; public class Browser extends Applet implements ActionListener { public void init() { Button b = new Button("go"); b.addActionListener(this); add(b); } public void actionPerformed(ActionEvent ae) { try { getAppletContext().showDocument(new URL("http://www.javasoft.com"), "_blank"); } catch(Exception e) { System.out.println("" + e); } } } javalicious P.S. Sorry for my english Norm February 28th, 2002, 09:52 AM Great article. Thanks. Norm brokenwing March 1st, 2002, 11:56 AM fantastic! this is broken wing! kannanbalu March 1st, 2002, 02:46 PM That's excellent. Thanks, Kannan codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved. |