Runtime.exec() works in Win98 but not in XP?

Hi all!
I have the following problem: I am using following lines of code in win98 to launch a MSDOS-window from my application (with some arguments to it):
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("start "+"command.com"+"/k"+"java -cp \""
+getArgument(directory,false)
+"\""+" "+getNoExtent(file));
proc.waitFor();
catch (Exception ex) {
ex.printStackTrace();
This works very well, however in XP it doesnt do a thing (I know that I have to change 'command.com' to 'cmd' or 'cmd.exe'). I have already tried that but it wont work. Instead, this exception occurs while running on XP:
java.io.IOException: CreateProcess: start cmd error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:63)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at JSEdit.actionPerformed(JSEdit.java:443)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1
113)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
d(BasicMenuItemUI.java:943)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
What should I do?
Thanx!
Regards
Veroslav

Check you string concatenation, you're missing spaces or you are not providing the actual code:
Process proc = rt.exec("start "+"command.com"+"/k"+"java -cp \""
+getArgument(directory,false)
+"\""+" "+getNoExtent(file));Let's dissect:
String command = "start ";
// command := "start "
command += "command.com";
// command := "start command.com"
command += "/k"+"java -cp \""
// command := "start command.com/kjava -cp\""You can always trace these kind of errors by using a debugger. Or dump the string you are passing to System.out. Every comprehensive IDE has a debugger built in, or you can resort to jdb.
Greets
Dhek Bhun.

Similar Messages

  • Runtime.exec work in windows but not in solaris??

    hi all,
    can someone tell me why the following code work in windows platform but doesnt work in solaris?The program tries to ping 127.0.0.1 and the output is correct in windows, but when i try it in solaris, it produces the following exception :
    Internal error: Unexpected Java exception thrown ( unknown exception, no description ) , stack:java.lang.NoClassDefFoundError: StreamGobbler
    at java.lang.Class.getDeclaredConstructors()(Native Method) ....
    The code is as follow:
    import java.util.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    class StreamGobbler extends Thread
         InputStream is=null;
         String type=null;
         PrintWriter out=null;
         StreamGobbler(InputStream is,String type,PrintWriter out)
         this.is=is;
         this.type=type;
         this.out=out;
         public void run()
              try
              InputStreamReader isr=new InputStreamReader(is);
              BufferedReader br=new BufferedReader(isr);
              System.out.println("finishing inputstreamReader and BufferedReader");
              String line=null;
              while (     (line=br.readLine())!=null )
                   {     out.println(type+"> "+line);
                        out.println("<br>");          
              catch (IOException ioe)
              {     ioe.printStackTrace();
    public class ping extends HttpServlet
         public void init(ServletConfig config) throws ServletException
         {     super.init();
         public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
              res.setContentType("text/html");
              PrintWriter out=res.getWriter();
         try     {
              Runtime rt=Runtime.getRuntime();
              System.out.println("pinging 127.0.0.1");
              String[] cmd={"ping","127.0.0.1"};
              Process proc=rt.exec(cmd);
              System.out.println("finishing process proc=rt.exec(cmd)");
              StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(),"ERROR",out);
              StreamGobbler outputGobbler= new StreamGobbler(proc.getInputStream(),"OUTPUT",out);
              errorGobbler.start();
              outputGobbler.start();
              int exitVal=proc.waitFor();
              out.println("Process exitValue: "+exitVal);
              out.close();
         catch (Throwable t)
                   t.printStackTrace();

    Did you copy all the class files to your solaris machine ? SOunds like you didn't copy all your files correctly.

  • Applets work in NS but not in IE

    Hello,
    I would very much appreciate tips on setting up sun java so that I can make applets that work in IE.
    Now, my IE have no problems with applets found on the web, for example this one is ok:
    http://java.sun.com/applets/jdk/1.1/demo/Animator/example1.html
    But, the examples installed with j2sdk1.4.1_07 will only work in Netscape. In IE these applets just display a grey applet area. (IE6/XP and IE5.5/Win98)
    So far:
    Have read installations instruction and ReadMe files. Installed j2sdk1.4.1_07, added PATH, code compiles fine. Console programs work ok. I also compiled a Hello World applet, which also worked in NS, but not in IE.
    Any help greatly appreciated.

    Me again...
    Right... Maybe I am answering my own question here? It seems that the programs compiled with j2sdk1.4.1_07 will NOT run under the JVM 1.1.4 from Microsoft Corp?
    So, anything that I compile with the later sun package will most likely fail on IE browsers unless the user have upgraded their JVMs?
    If so, then what version of Sun Java can be recommended to achieve reasonable amount of compatibility with the IE5.5 and IE6 that are out there?

  • Applet works in Netscape but not IE

    Very basic Hello World applet. IT doesn't work in IE 6. Not sure why.
    html source:
    <html>
    <body>
    <applet code="test.class" Width=640 Height=480></applet>
    </body>
    </html>
    Anyone know why?

    I do have java runtime installed. I used java SDK 1.4.1. What runtime do I need installed for applets made with this version of java? I have the 1.4.1 runtime installed. It doesn't make sense to me that it would work in Netscape but not Internet Explorer. Any help would be great. Thax

  • Custom F4 help in a BSP application working in Mozilla but not in IE

    Hi,
    I have created a custom F4 help in a BSP application.
    It is working in Mozilla but not in IE. I tried enabling javascript as well but still it is not working.
    Can someone please suggest a possible solution for this?

    Hi,
    See simmilar discussion in thread /thread/1883519 [original link is broken]
    I think this may be helpful for you.
    Thanks,
    Chandra

  • Why does the counter work in MAX, but not Labview?

    Please help, I have been away from Labview for over 3 months, and I am quite rusty....
    Last year, I successfully configured NI9401 to measure period (seconds) by counting the rising edges of my sensor signal.  Since then, I have aquired a new PC, and loaded all my software into it, including the Labview VI's that successfully worked on the old computer.
    I can see the digital signal using MAX and the test panel for the NI9401, so, I know my wiring and my TTL signal is OK, but, when I try to run the attached VI, nothing happens except the error below..  How do I tell this VI to look for the signal on MOD3/CTR0 and channel 14?
    Thanks. I am sure it is a small adjustment...this worked fine a few months ago...not sure what is wrong now.
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    continuously measure period buffered_singlechannel_forum_feb_23_2012.vi ‏20 KB

    OK, now.  Resolved the issue. The vi is fine, but, some shaky wires were identified...worked in MAX but not in the vi.  Now that the connections have been tightened up, it works for both.  Sorry for the inconvenience.
    Dave

  • Works on emulators but not on mobile devices

    Hello,
    My project works on emulators but not on mobile devices (no image and on Samsung it says "unsupported file").
    Please help, I don't know what to do. My configurations: MIDP 2.1, CLDC 1.1.
    Thanks in advance.
    Edited by: Vitali.pom on Oct 27, 2011 12:01 PM

    Edit: I succeeded to solve it accidentally. I did the following: Sign the jar in Netbeans, clean and build, the jar didn't work, I wiped out the .ks from the jar and clean and build again. Now it worked.
    Edited by: Vitali.pom on Oct 30, 2011 1:28 AM

  • Wifi works at home but not when away from home

    My Wifi works at home but not when away from home, what is wrong?  I thought with a phone plan I didn't need to have a wifi connection.

    You either need WiFi or Cellular (or both). If you have neither, you can't connect to the internet.
    Most people use WiFi at home and Cellular while away from home, or connect to public WiFi networks where there are some.

  • Can't FaceTime anymore?  iPad states wifi connected and iPhone 4 states not connected?  I have wireless in my home? Not sure what happened.  Password works for iPad but not on phone?

    iPhone won't connect to wifi.  iPad is connected.  Password working on iPad but not on phone.  Can't upload software update of IOS 7.1 because phone not connecting to wifi?

    Connect iPhone to computer and open iTunes.  You will be prompted to update to iOS 7.0.  Keep your phone connected until the update is finished.

  • My apple id works on itunes but not on my ipod touch, what gives ?

    my apple id works on itunes but not on my ipod touch, what gives ?

    What are you trying to do on the iPod?
    Have you went to Settings>Store and sign out and then sign back in?

  • Album Art works for most, but not all

    I was reading previous forums on the subject, but no clear answer was given..
    The album art shows up fine in itunes and my library and works for most of my music on my ipod, but how come some album's art does appear? I have it set manually and select 'Get Info' then 'Artwork' and add it from there, then drag in the finished product to my ipod. I've been doing that and it works fine for most of the albums, but every so often, the album art will not appear on my ipod. Am I doing something wrong? I take them all from the same source (amazon.com) but it makes no sense to me how some randomly don't appear.
    I tried deleting the artwork and re-adding it, but nothing happened again. If you could answer why it works for most but not all or how I can get the album art to appear for the ones it will not by re-doing something, it would be appreciated. thanks.

    I encountered the same problem in the beginning. When I compared the size of the original images, the working ones seemed to be smaller in general, so I reduced the size of all covers I intended to upload on the pod to 300x300 pixels.
    This seemed to work - for 2 days. I bought the pod on friday, had pictures on sunday, but on Monday (after the first time the pod was fully discharged) none were left left.
    So I ended searching this forum for related problems...
    And decided to join my problem to this entry.

  • How to send active links in email from firefox. Works in IE but not Firefox... Is there a setting to change?

    how to send active links in email from firefox. Works in IE but not Firefox... Is there a setting to change?
    == This happened ==
    Every time Firefox opened
    == Always

    Check with your web mail service provider for help with that issue.

  • Medical app from Intuit works in IE, but not Firefox.

    Encrypted medical app works in new IE, but not Firefox. Everything works down to the end, and click on "continue" and nothing happens. A tech and I have spent hours on this. Did not work on FF5 or 6. Did not work on old IE, but did on fresh new version with no data files copied in.

    If it works in IE but not FF, then it has nothing to do with the mp3s. More likely it's because of the HTML on the page.
    To start, page is missing DOCTYPE declaration... a MAJOR problem. The DOCTYPE declares which set of rules the browser will use to display the page. Without it, different browsers go crazy or do not work at all.
    http://www.w3schools.com/tags/tag_DOCTYPE.asp
    Validate the html code here:
    http://validator.w3.org/
    You will have to fix all the errors if you want this to work in all browsers.
    Best wishes,
    Adninjastrator

  • Flash Player works in Safari but not Internet Explorer 9

    I've installed Flash Player 10.3 and it works in Safari but not Internet Explorer 9. When I look in Manage Add-Ins I see Flash Shockwave but not Flash Player. My operating system is Windows Vista Ultimate (32bit). Safari is 5.0.5 and IE 9 is 9.0.8112.16421. I've tried uninstalling and re-installing Flash Player and uninstalling Norton 360. Nothing has worked so far. Can you help?

    Thank you for your reply. Shockwave is loaded and enabled.
    The files in flash directory are: a folder called FlashPlayerTrust: file, flash10q.ocx: file, FlashInstall.log; file, FlashUtil10q_ActiveX.dll; file, FlashUtil10q_ActiveX.exe, file, install.log.
    There is no file: NPSWF32.dll.
    When I test the browsers I get no spinning logo in either Safari or IE9. Safari says: missing plug-in, where I think the logo should be. IE-9 says nothing at the same location.
    Thanks.

  • Navigation works in IE but not Firefox or Safari!

    Hi guys
    Why do my nav links on the hompage work in IE but not in Firefox and Safari? http://www.jasonkieck.com/
    Any help would be appreciated

    The main reason is you have a <div id="bg_grid"> at the end of your html that is essentially over the top of everything else on your page, including your links. All clicks go to that <div> rather than your links undeneath it. I'm kind of surprised it works in IE to be honest.
    You do also have a ton of errors as Gramps points out, but that particular issue is not technically an error, so I have a feeling you could fix the ~100 problems shown by the validator and still have the issue.
    You could use z-index to "order the stack" as it were. Changing the z-index attributes for the css of those elements will allow you to change their order, regardless of their location in the html. A higher z-index number, the "closer" it is to the viewer (higher on the stack).
    Right now, they are both set to 1, so the one that comes later in the html is on top.
    Adding z-index:999 to the menu <div>  should do it,

Maybe you are looking for