• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to prevent a MS DOS window popping up when I run cmd.exe from java

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a GUI application which has to do a lot of IO. This was making it too slow. To improve the performance I tried using xcopy to do the copying



It worked much faster but now I am having a new problem a MS Dos window keeps popping out every time I run the xcopy which is a real eye sore.

googling around I get a feel that the best I can do it to minimise it.

But before giving up I wanted to ask the ranchers is there and way a simple trick, workaround where I can continue to use xcopy and not have the cmd window popping up.

any help in this will be greatly appreciated


-Rajagopal
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of running cmd.exe to run xcopy, have you tried running xcopy.exe directly?

Henry
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry,

Thanks for the reply.

I tried


but it did not work.

is there any other way workaround by which I can keep those windows from popping up.

Thanks,
Rajagopal
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rajagopal Manohar:
Hi Henry,

Thanks for the reply.

I tried


but it did not work.

is there any other way workaround by which I can keep those windows from popping up.

Thanks,
Rajagopal



There is really no reason for it to not work. Try to see the errors it produces, by checking its output. See Process methods getOutputStream, getErrorStream.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the Java Intermediate FAQ for some advice on how to use Runtime.exec.
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Guys,

Thanks for the replys, but the issue at hand is not how to get Runtime.exec() to work. I figured that one myself.

I am just desperate to know how to supress the dos command promt that pops up after running it.

Any pointers will be greatly appreciated

-Raj
[ November 16, 2005: Message edited by: Rajagopal Manohar ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I want to run scheduled tasks without the aweful cmd window, I create a .vbs file. Below is an example of a running a scheduled Java application without the cmd window. You might try putting the commands you need to do your XCopy into a .vbs file. Just a suggestion.

Set ws= CreateObject("WScript.Shell")
ws.Run("F:\Java\jdk1.3.1_04\bin\javaw -cp .\\Multiples.jar;.\\Auxiliary.jar;F:\\Java\\j2sdkee1.3\\lib\\j2ee.jar serverTester.ReportSender GovHUB02 Rick.Lohmeyer true")
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rick,

Great idea, can you go just one step futher to help me and let me know how to write a vbs script to do xcopy or atleast where I can learn to do it.

One more thing how to run vbs script from within java, ie are vbs scripts executable in the sense exe's are.

I am really very ignorant about these things, please help me

-Raj
 
Hemal Pandya
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rajagopal Manohar:
Hello Guys,

Thanks for the replys, but the issue at hand is not how to get Runtime.exec() to work. I figured that one myself.

I am just desperate to know how to supress the dos command promt that pops up after running it.

Any pointers will be greatly appreciated

-Raj

[ November 16, 2005: Message edited by: Rajagopal Manohar ]



What does "does not work" mean. I wrote a small program to test, and it works. That is, it copies the files and does not pop-up the command window.

Can you post your code and describe what happens when you run it?
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Hemal Pandya:


What does "does not work" mean. I wrote a small program to test, and it works. That is, it copies the files and does not pop-up the command window.

Can you post your code and describe what happens when you run it?



Hi Hemal,

If you run a standalone program from the command line I expect things to work out well.

But I am running it from a GUI application. An eclipse pluginm, when we do that a Dos command promt pops up when we run the xcopy. This command promt is what I want to supress. I just want to know is there a better way than just minimising it.

any help will be appreciated.

-Raj
 
Hemal Pandya
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rajagopal Manohar:

[swing causes dos window to pop-up on Runtime.exec("xcopy")]



Can you post some *small* sample code that demonstrates this?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic