aspose file tools*
The moose likes Java in General and the fly likes runtime exec of command.com mkdir malfunction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "runtime exec of command.com mkdir malfunction" Watch "runtime exec of command.com mkdir malfunction" New topic
Author

runtime exec of command.com mkdir malfunction

John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
If I get a command.com window and execute

it works perfectly. (I'm on an XP Home System)
But when I run a Java app to do the same thing via
runtime.exec() as in:


then the make directory command is limited to creating directories that have a maximum of 8 characters in their name.

Why is this? And how can I get the runtime.exec() process to execute a command.com mkdir internal command intrepeter command that creates directories with 9 or more characters?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

And you can't use CMD.EXE because...? Or, for that matter, java.io.File.mkdir() ?


[Jess in Action][AskingGoodQuestions]
John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
Ernest,

I tried cmd.exe and everything worked perfectly. Thanks very much for your input.
I'm going to be using cmd.exe for a long list of function invocations in the windows environment some of which don't nave a java equivalent (such as net stop and start for windows services), so I wanted to be consistent in my Java app.

However, I would appreciate further information as to what needs to be considered when choosing between command.com and cmd.exe. My information (which is obviously sketchy and flawed) was that cmd.exe should be used for NT and command.com for everything else (Windows 95, 98, XP, ME, etc.).
This is obviously incorrect and I would very much like to be set straight on this matter.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

To answer your last question: you're correct except that you put XP in the wrong pile. If Windows 2000 was NT 5, then XP is "NT 6". 95/98/ME basically follow the old "shell on top of DOS" model, whereas the NT OSs are a complete OS in themselves.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
command /?

and

cmd /?

are pretty good. The big thing to notice is one is a "MS-DOS command interpreter" and the other is a "Windows NT command interpreter".


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html


Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: runtime exec of command.com mkdir malfunction