Complementando, segue um detalhe sobre o uso do exec()..
> I want to run a system command with exec, such as in
>
> Runtime.getRuntime.exec( " dir /w");
>
> However catching and printing the related exception ( IOException )
> results in :
> java.io.IOException: CreateProcess: dir /w error=0
> which means the createprocess for the new process failed .
The reason this doesn't work is that "dir" is a builtin command of
command.com (or cmd.exe). Runtime.exec() starts a process rather than
executing a command in a command shell. Therefore "dir" and similar
commands will not work. If you want to do this sort of thing, you might
want to create a batch file and exec the batch file instead, or just use
the standard java.io.File stuff for listing the contents of directories.
Se voc� vai utilizar com o ls do Unix, n�o h� problemas (pra dizer a verdade
n�o tirei a prova :-D)... s� tenha em mente que esta n�o � a maneira mais
"elegante" de se conseguir os arquivos de um diret�rio.. :-)
Fl�vio Eduardo de C�rdova
Datasul S/A
Ferramentas
Sun Certified Java Programmer 1.1
"If you don�t know where you want to go, any road will take you there"
> -----Original Message-----
> From: Roger Steuernagel [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, February 22, 1999 4:30 PM
> To: Lista de discussao sobre java da Sun-br
> Subject: RE: executando comandos
>
> Runtime.getRuntime().exec("o comando");
>
> Roger Steuernagel
>
> Sun Certified Java Developer 1.1
> Microsoft Certified Professional
> Technical Support Analyst
> Tecnology Center @ Datasul S.A.
>
> > -----Original Message-----
> > From: Alysson Neves Bessani [SMTP:[EMAIL PROTECTED]]
> > Sent: Monday, February 22, 1999 5:11 PM
> > To: Lista de discussao sobre java da Sun-br
> > Subject: executando comandos
> >
> >
> > Amigos
> >
> > Existe algum metodo em java que execute um comando do sistema
> > operacional? Tipo o System do C. Ex: System("ls -la");
> >
> > Eu queria chamar o compilador de dentro de um aplicativo em java,
> > existe outro jeito de fazer ou soh por metodos nativos?
> >
> > Obrigado.
> >
> >
> > --
> > Alysson Neves Bessani
> > [EMAIL PROTECTED]
> > LES- Software Engineering Laboratory
> > CTC- Tecnological Center
> > UEM- Universidade Estadual de Maringa
> >
> > "I felt your hair across my skin
> > I didn't know where to begin
> > A shallow promisse in my ear
> > No thoughts, no dreams, no wishes, and no fear"
> > "Thorn" - My Bloody Valentine
> >
> > * Para nao receber mais e-mails da lista, acesse
> > <http://www.sun.com.br:8080/guest/RemoteAvailableLists>, coloque seu
> > e-mail, escolha a lista <[EMAIL PROTECTED]> e de um <submit>.
> * Para nao receber mais e-mails da lista, acesse
> <http://www.sun.com.br:8080/guest/RemoteAvailableLists>, coloque seu
> e-mail, escolha a lista <[EMAIL PROTECTED]> e de um <submit>.
* Para nao receber mais e-mails da lista, acesse
<http://www.sun.com.br:8080/guest/RemoteAvailableLists>, coloque seu e-mail, escolha a
lista <[EMAIL PROTECTED]> e de um <submit>.