Runtime.exec() for different Windows versions ?

Hello all.
I'm currently developing a Java program that uses Runtime.exec() to launch a MS-DOS application (the old MS-Kermit). It works fine under Windows ME and Java 1.3.1 but the very same code fails to work under Windows 2000. That's very bad for me, since my program should work on all windows platforms from 95 up to XP (and NT).
My question is : can I trust Runtime.exec() or am I damned to write different versions of the same command for different operating systems ?
Thanks.

Runtime is not os independent, so yes, it has to accomodate the os differences. There is an enhancement request on the subject, tho.
Search the forums, there is code that handles the differences posted.

Similar Messages

  • They sent me a serial number for a windows version of PS Elements when I ordered a mac version.  The serial number doesn't work, not surprisingly, but they don' t seem to care.  I have tried the chat line and have waited for almost a day with no response.

    They sent me a serial number for a windows version of PS Elements when I ordered a mac version.  The serial number doesn't work, not surprisingly, but they don' t seem to care.  I have tried the chat line and have waited for almost a day with no response.  What should I do?

    Look here
    Order product | Platform, language swap

  • How to set different icons for different windows which is seen in the top left corner?

    Hi
    How to set different icons for different windows which is seen in the top left corner? I know when building exe there is a option to edit icons or add icons and that icon is default for all the windows in the project. But i want different icons for different windows which is possible in VB.
    Is there any way to set icon by calling any dlls.
    Thanks & Regards
    Samuel J
    [email protected]

    Hi Sam,
    no problem. See the attachment.
    Mike
    Attachments:
    TestIcon_LV85.zip ‏44 KB

  • Can I change my Mac version of Flash for a Windows version?

    Hey, I bought Flash Pro CS3 for Mac and was wondering if
    there was any way I could change my Mac version for a Windows
    version? Any help is appreciated.

    This is a good question for Adobe support, we are just users
    on this board.
    I really don't know. You could try downloading the trial for
    PC, installing it, then see if your Mac license key works to
    activate it. My guess is that it will not, but it's worth a try.
    But again, to really get this resolved you should contact
    Adobe support.
    Good luck.

  • Small runtime engine for newer labview versions?

    A few times in the past I have created simple LabVIEW standalone executibles.  I did this in 8.6 and used the runtime engine minimal installer instead of the full version.  This resulted in an installation package size of 30-35 Meg.  
    I agin need to create a simple executible but have not seen a minimum runtime installer for any LabVIEW version since 8.6 
    Are there any minimal runtimes for other versions? 
    The default 2014 runtime is 264 Meg!!!  It is hard to explain to a customer why a simple "Hello World" program requires a 200+ Meg download.
    Solved!
    Go to Solution.

    Jack Dunaway has documented a way of segmenting the run time engine, basically only including the pieces of it you need.
    https://connect.wirebirdlabs.com/knowledgebase/articles/172999-segmenting-the-run-time-engine
    And here is an idea exchange item on it.
    http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Segment-the-LabVIEW-Run-Time-Engine-RTE-to-ONLY-Necess...
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Runtime.exec and locked window

    So I'm working in a Swing application guaranteed to run only on Windows systems using Java 1.6 u 7. The users want a help button to launch a local web browser and point to the company's web site.
    After reading online and finding that getDesktop.browse() sometimes crashes in that version of Java, I use Runtime.exec("rundll ...") to kick off the local browser with the appropriate web address.
    The browser comes up appropriately, but the original Swing application's mouse pointer converts to an hourglass; I can click on the original window and get results but I can't open a new window.
    So I create a short thread implementing the Runnable interface and put the Runtime.exec call in that thread; I assume the problem is that the process is interfering with the GUI thread, and putting the Runtime.exec call in a separate thread will clear the problem up. It doesn't work; I still have the hourglass.
    I read online that some processes require that their input and error streams be consumed, or they may block; That shouldn't be a problem with internet explorer, but I add two threads to consume those streams; still no change.
    I also tried getDesktop().browse() anyway, and in a separate thread, and had the same problem.
    Does anyone have any suggestions?
    Respectfully,
    Brian P.

    Okay.
    First, let's look at the basic client.
    As you can see, when asked to show a window,
    it puts it in a separate thread for rendering:
    public class Client     
    // Show one example method
         private void showNewWindow(Window window)
              ourLogger.info("New request to display window: " + window.getClass().getName());
              if (window instanceof ClientWindow)
                   try
                        ((ClientWindow) window).bindFrames();
                        ((ClientWindow) window).setClient(this);
                        if (window instanceof ClientJDialog)
                             window = new ClientJDialog((ClientJDialog) window);
                        else
                             correctSize(window);
                        showCenter(window);
                        synchronized(myWindows)
                             myWindows.add(window);
                        counter = 0;
                        thread.hide();
                   catch (Exception re)
                        ourLogger.error("Client error while trying to show window", re);
                        ((ClientWindow) window).unbindFrames(false);
              else
                   throw new Error(window.getClass().getName() + " is NOT an instance of ClientWindow");
    // Snip some more
    At this same level on this class, I had originally put a showHelp() procedure with a single
    command thus:
         public void showHelp()
              Desktop.getDesktop().browse(java.net.URI.create(<help web site>));
    Simple, eh? But that gave me the hourglass as discussed. So I pushed it into a new thread.
    It eventually mutated thus:
         public void showHelp()
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
              //windows only
              Runtime rt = Runtime.getRuntime();
              Process p = rt.exec("rundll32 url.dll,FileProtocolHandler " + "<help URL>");
              StreamGobbler s1 = new StreamGobbler ("stdin", p.getInputStream ());
              StreamGobbler s2 = new StreamGobbler ("stderr", p.getErrorStream ());
              s1.start ();
              s2.start ();
              try {
              p.waitFor();
              } catch (java.lang.InterruptedException e) {}
    So as you can see, I ditched Desktop from Runtime and added a pair of stream consumers
    to ensure I wasn't having the stream problem our second poster discussed. Still no joy.
    I eventually replaced the url call with an attempt to invoke a simple batch file which
    did nothing, and I still had the same problem. I still have an hour glass, even when
    the process has been pushed into a new thread as you can see.
    Respectfully,
    Brian P.
    Edited by: pendell on Apr 16, 2010 3:14 PM

  • Runtime.Exec for 'appref.ms' files

    Hello!
    I am using Runtime.exec to call an external application from java classes. These classes are in turn used by JSP.
    The external application is an "Application Reference" type application in Windows, and has the extension appref.ms
    From Glassfish logs, I can see the following error:
    java.io.IOException: Cannot run program ""C:\Documents and Settings\Administrator\Start Menu\Programs\ProTeleCo\QuotEncrypt.appref-ms"": CreateProcess error=193, %1 is not a valid Win32 application
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
        at java.lang.Runtime.exec(Runtime.java:593)
        at java.lang.Runtime.exec(Runtime.java:466)
        at list.CreateNew.runExternal(CreateNew.java:251)
        at list.CreateNew.CreateQuotationDR(CreateNew.java:222)
        at list.CreateNew.processRequest(CreateNew.java:88)
        at list.CreateNew.doPost(CreateNew.java:143)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
        at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
        at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
        at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
        at java.lang.ProcessImpl.start(ProcessImpl.java:30)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
        ... 35 moreWhen I open a command window and type
    "C:\Documents and Settings\Administrator\Start Menu\Programs\MyCompany\QuotEncrypt.appref-ms" <arg1> <arg2>
    The program runs without problems.
    I actually tried copying the QuotEncrypt.exe file that is built in the development environment to the server and give that as argument to Runtime.exec, but in that case the application seems to run (I use waitfor and the return value from waitfor) , return with 0, but it has no side effects. It does not even write to its log file.
    Hence I am at a loss to what to do.
    Appreciate any help,
    Irem

    And now the program hangs.
    It seems to be time for code indeed:
    String[] commands = {"C:\\WINDOWS\\system32\\cmd.exe", " /start ", Constants.QuotEncryptPath, " \""+qfile + "\"", Constants.encryptPassword};
      runExternal(commands);
          public static void runExternal(String commands[])
            try
                Runtime rt = Runtime.getRuntime();
                System.out.println("Execing ");
                String whole="";
                for(int i =0; i < commands.length ; i ++)
                whole = whole + commands;
    System.out.println(whole);
    Process proc = rt.exec(commands);
    // any error message?
    StreamGobbler errorGobbler = new
    StreamGobbler(proc.getErrorStream(), "ERROR");
    // any output?
    StreamGobbler outputGobbler = new
    StreamGobbler(proc.getInputStream(), "OUTPUT");
    // kick them off
    errorGobbler.start();
    outputGobbler.start();
    // any error???
    int exitVal = proc.waitFor();
    System.out.println("ExitValue: " + exitVal);
    } catch (Throwable t)
    t.printStackTrace();
    import java.io.*;
    import java.util.*;
    * @author iaktug
    class StreamGobbler extends Thread
    InputStream is;
    String type;
    StreamGobbler(InputStream is, String type)
    this.is = is;
    this.type = type;
    @Override public void run()
    try
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    while ( (line = br.readLine()) != null)
    System.out.println(type + ">" + line);
    } catch (IOException ioe)
    ioe.printStackTrace();
    I got the code from the famous when Runtime.exec() won't. I am now suspecting there is something wrong with this part.
    Essentially I want a very simple thing. The external program will run and the parent program will wait for it and get the return value.
    I added the Stream stuff simply to prevent deadlock/hanging.
    I am considering trying to get that out completely.
    The server messages go as follows:....
    Execing |#]
    [#|2009-12-17T09:42:40.499+0400|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=878233;_ThreadName=httpSSLWorkerThread-8082-4;|
    C:\WINDOWS\system32\cmd.exe /start "C:\Documents and Settings\Administrator\Start Menu\Programs\ProTeleCo\QuotEncrypt.appref-ms" "H:\QUOTATIONS\Quotations\In Progress\q00502.xls"1q2w3e|#]
    [#|2009-12-17T09:42:40.499+0400|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=878234;_ThreadName=Thread-923673;|
    OUTPUT>Microsoft Windows [Version 5.2.3790]|#]
    [#|2009-12-17T09:42:40.499+0400|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=878234;_ThreadName=Thread-923673;|
    OUTPUT>(C) Copyright 1985-2003 Microsoft Corp.|#]
    [#|2009-12-17T09:42:40.499+0400|INFO|sun-appserver2.1|javax.enterprise.system.stream.out|_ThreadID=878234;_ThreadName=Thread-923673;|
    OUTPUT>|#]

  • Runtime exec opens new window

    Hi, I am using Runtime.exec to run an external application in Windows2000. � can read its output and i can destroy it without any problems.
    But when i run my java application with javaw , the external application i run with rt.exec opens new window(without output texts, empty) . just output command windows which opens when i run the external app. from a command prompt.
    If i run my java application with java.exe then then external application DO NOT open new window and run correctly. But this time my java window stays on desktop, and that's not any good for a Windows Application.
    In both cases everything runs OK. The only problem is the command prompt windows.
    Is there a solution when working with javaw.exe ? or hide the window when running with java.exe
    Thanks all.

    bug with ID: 4244515

  • Runtime.exec error in windows

    When i try to run an external program with Runtime.exec() in windows 2000, i get a windows pop-up with the following error msg:
    d:\winnt\system32\ntvdm.exe
    Error while setting up environment for the application.
    I have no idea how to fix this since i have no clue to what that error means.
    Thanks
    Rumy

    I've personally just encountered the same error. I am building a piece of demonstration software to distribute with my graduate school applications to demonstrate my programming experience and I wish to include a set of programs I wrote some years ago in Pascal and C++. The software has been compiled for MS-DOS 6.0. I am using the following command to execute the software from within my Java program:
    Runtime.getRuntime().exec(new String[]{"command.com","/c","12cards.bat"});The batch file performs the appropriate setup operations for the program and runs the executable. When I run this code segment, I receive the following error:
    [16 bit MS-DOS Subsystem]
    C:\WINNT\system32\ntvdm.exe
    Error while setting up environment for the application. Choose 'Close' to terminate the application.
    I have another code segment in which I attempt to run the executable myself (without the help of command.com or the batch file). The code segment is as follows:
    Runtime.getRuntime().exec(new String[]{"12cards.exe"}, new String[0], workingDir);When I run this code segment, the following IOException is thrown:
    java.io.IOException: CreateProcess: 12CARDS.EXE error=2
         at java.lang.Win32Process.create(Native Method)
         at java.lang.Win32Process.<init>(Win32Process.java:66)
         at java.lang.Runtime.execInternal(Native Method)
         at java.lang.Runtime.exec(Runtime.java:566)
         at (my code)I have already found the document on Microsoft's support website which describes a solution to this problem. Manually extracting the autoexec.nt, config.nt, and command.com files from the installation CD-ROM did not help.
    The most confusing element of this: 12CARDS.EXE runs fine if I execute it from Windows Explorer. It's only a problem if it's executed from within my Java program. I have two other DOS programs which I want to include as well; I am having the same trouble with them.
    Any advice will be much appreciated. Thanks!

  • Make can't recursively call Make when run from Runtime.exec (for some user)

    This one is a little complicated. The afflicted platform is Mac OS X. It works fine on Linux, it seems, and even then, it does work for some Mac OS X users...
    First, the setup. I have a Java program that has to call GNU Make. Then, GNU Make will recursively call Make in some subdirectories. This results in the following Java code:
    String make = "make"; //on windows, I have this swapped with "mingw32-make"
    String workDir = ...; //this is programmatically detected to be the same folder that the parent Makefile is in
    Runtime.getRuntime().exec(make,null,workDir);This calls make on a Makefile which has the following line early on to be executed (this is only a snippet from the makefile):
    cd subdirectory && $(MAKE)When I fetch the output from the make command, I usually get what I expect: It cd's to the directory and it recursively calls make and everything goes smoothly.
    However, for one particular user, using Mac OS X, he has reported the following output:
    cd subdirectory && make
    /bin/sh: make: command not found
    make: *** [PROJNAME] Error 127Which is like, kinda hurts my head... make can't find make, apparently.
    I've gotten some suggestions that it might be due to the "cd" command acting wonky. I've gotten other suggestions that it may be some strange setup with the env variables (My Mac developer is implementing a fix/workaround for 'environ', which is apparently posix standard, but Mac (Mr. Posix Compliance...) doesn't implement it. When he finishes that, I'll know whether it worked or not, but I get the feeling it won't fix this problem, since it's intended for another area of code entirely...
    Also worth mentioning, when the user calls "make" from the terminal in said directory, it recurses fine, getting past that particular line. (Later on down the road he hits errors with environ, which is what my aforementioned Mac dev is working on). Although calling "make" by hand is not an ideal solution here.
    Anyways, I'm looking for someone who's fairly knowledgeable with Runtime.exec() to suggest some way to work around this, or at least to find out that perhaps one of the User's settings are wonked up and they can just fix it and have this working... that'd be great too.
    -IsmAvatar

    YoungWinston
    YoungWinston wrote:
    IsmAvatar wrote:
    However, for one particular user, using Mac OS X, he has reported the following output:One particular user, or all users on Mac OS?In this case, I have two mac users. One is reporting that all works fine. The other is reporting this problem.
    cd subdirectory && make
    /bin/sh: make: command not found
    make: *** [PROJNAME] Error 127Which is like, kinda hurts my head... make can't find make, apparently.If that is being reported on the command line, then I'd say that make wasn't being found at all.If make isn't being found, then who's interpreting the Makefile?
    It's also just possible that the make script on Mac isn't correctly exporting its PATH variable, though it seems unlikely, since this would surely have been reported as a bug long ago.
    I've gotten some suggestions that it might be due to the "cd" command acting wonky...Also seems unlikely. 'cd' has been around since shortly after the K-T extinction event.
    WinstonBy "acting wonky", I mean being given a bad work directory or some such, such that it's not changing to the intended directory.
    Andrew Thompson
    Andrew Thompson wrote:
    (shudder) Read and implement all the recommendations of "When Runtime.exec() won't" (http://www.javaworld.com/jw-12-2000/jw-1229-traps.html).
    Already read it. I already know the dreadful wonders of Runtime.exec. But in this case, it's been working fine for us up until one Mac user reported that make can't find make.
    Also, why are you still coding for Java 1.4? If you are not, use a ProcessBuilder, which takes a small part of the pain out of dealing with processes.Usually I do use a ProcessBuilder. I noticed that it usually delegates to Runtime.exec() anyways, and seeing as I didn't need any of the additional functionality, I decided to just use Runtime.exec() in this particular case.
    jschell
    jschell wrote:
    So print thos env vars, in your app and when the user does it.I'll look into that. It's a good start.
    -IsmAvatar

  • Runtime.exec and dialog windows

    I'm using Runtime.exec to launch an exe that may crash due to runtime errors (such as division by zero). When this appens a dialog window shows up, waiting for the user to close it. (I'm running the program under Win98). Is there a way to avoid this?

    I think the only way should be fixing the exe bug!
    There is no way, I suppose.
    Ciao!

  • How do I access open tabs from other devices in Firefox 4 for desktop (windows version)

    I want to see the open tabs from other devices but I can't find how to access it.
    Where do I find them in firefox 4?
    I use the windows version.
    Thank you!

    This is for all versions (image attached below):
    1. In the top navigation (you might have to press the ALT key to reveal the menu), navigate to '''History - Tabs From Other Computers'''
    2. Alternatively; open a new tab and type '''about:sync-tabs''' then press enter.
    NB: When you open a tab in the 'Tabs From Other Computers' window it '''WILL NOT''' remove that tab from the other device.

  • Can I have a primary database and standby database with a different windows version?

    Hi
    I need your help.
    We need to increase the memory in the server where is the standby database , but first, we need to upgrade the windows version.
    The actual version is windows 2003 standard edition 64 bits
    The new version will be windows 2003 enterprise  edition 64 bits
    This difference in windows version  between primary and standby servers can cause a problem in the synchronization between primary and standby databases ??
    What do you recommend? Have both servers in the same windows version?
    The databases are in SQL SERVER 2005.
    Thanks.
    Loreinn

    This difference in windows version  between primary and standby servers can cause a problem in the synchronization between primary
    and standby databases ??<o:p></o:p>
    There is no issue with database synchronization as long as SQL Server is of same version.<o:p></o:p>
    What do you recommend? Have both servers in the same windows version?<o:p></o:p>
    OS(Windows version) has no restriction for using SQL server 2005 database mirroring/log shipping. You can go with upgrade without any worries on SQL
    database side.<o:p></o:p>

  • Runtime.exec() opening dos window.

    I heard that in newer version of java (>java 1.2 ) if Runtime.exec() is used to execute some native program, a black dos promt is popped up automatically and closed when the execution of the native program is completed.
    Will this happen every time I use Runtime.eceX()? is there a way to avoid this opening of dos prompt.

    It will vary by os version. Read up on the use of the command or cmd statements from the os help information, and on the os's start command (may not exist in all os's)
    Experiment fron the commandline to see what happens.

  • Feature request for the windows version section..

    Does there exist anywhere to raise feature requests for any future releases of MBSA?
    The additional system information section of the report, and "windows version", it would be useful if it could include service pack number number, as well as flag it as a vulnerability (red X) if the version/SP level identified is out of Microsoft
    support. That would be very useful.

    For request like this you need to go here to the itunes feedback page http://www.apple.com/feedback/itunesapp

Maybe you are looking for

  • Can I remove iPod for Windows 2006-03-23 and 2006-06-28?

    I have the latest update of iTunes installed on my PC. I'm trying to remove uneeded programs from my c drive. Is it safe to remove iPod for Windows 2006-03-23 and iPod for Windows 2006-06-28? If I removed them will it adversely affect the restoring o

  • How to move a money value from java to Flex

    According to http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDo cs_Parts&file=00001103.html I can pass a Double, Float, Long, Short, BigDecimal or the primative equivalent types from java to Flex and they will

  • How can I get rid of the display of the last played music-title

    How can I get rid of the display of the last played music-title When playing a music-title the name of the title and it's progress is displayed in the box at the top of iTunes, even if the music is already stopped or ended. This display is impeding f

  • Error using p_publish_date in add_item function

    Hi, I use the add_item function to add an item to a page. When I use the publish date parameter (p_publish_date) I get the error: ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at "PORTAL.WWSBR_API", line 8

  • BW or Xi?

    Hi all, Please help me. I have gone through the training of BW and Xi. and i have offer in both technology. Please tell me in which technology should i move?  Regards, Neeraj