Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2005

Tip: Looking for answers? Try searching our database.

Running command line commands in java program

Thread view: 
:) - 05 Mar 2005 22:32 GMT
We are trying to run a command line command, namely wget, in our java
program. Is there a way to do something like 'wget http://www.cumtd.com'?
Daniel Tryba - 05 Mar 2005 22:54 GMT
> We are trying to run a command line command, namely wget, in our java
> program. Is there a way to do something like 'wget http://www.cumtd.com'?

See the Runtime class (esp Runtime.exec(String command))
Tony Morris - 06 Mar 2005 07:43 GMT
> We are trying to run a command line command, namely wget, in our java
> program. Is there a way to do something like 'wget http://www.cumtd.com'?

URLConnection con = new URL("http://www.cumtd.com").openConnection();

"If all you have is a hammer, everything looks like a nail"
http://c2.com/cgi/wiki?GoldenHammer

Don't be a victim.
99% of the time I've seen a system call or the use of JNI, it was for the
wrong reason.

Signature

Tony Morris
http://xdweb.net/~dibblego/

John Resler - 17 Mar 2005 06:08 GMT
I agree with the Runtime.exec method but it is not portable. Java's
design was really built around
the Unix model of processes, etc. and Windows command line programs are
hindered by the lack
of a true shell interpreter like Bash or the Korn Shell. Nonetheless, it
is fairly simple to start a process
up and monitor it's output. The difficulty I'm having is controlling
external processes with Java. Perhaps
this is asking to much of Runtime.exec. In any event, here's a link to a
good article on using Runtime.exec.
Cheers.

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html

-John

>  
>
[quoted text clipped - 12 lines]
>
>  


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.