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 / General / November 2005

Tip: Looking for answers? Try searching our database.

start external program from Java

Thread view: 
grz01@spray.se - 07 Nov 2005 12:31 GMT
Java newbie question..

In windows, if I want to start another application from Java-code,
(like notepad.exe or invoke a document c:\mydoc.htm with my
default-browser)
what class/method do I use in Java?

TIA,
------------------------------------------ grz01
Andrew Thompson - 07 Nov 2005 12:44 GMT
> Java newbie question..

Note that a good group for those new to Java is ..
<http://www.physci.org/codes/javafaq.jsp#cljh>

> In windows, if I want to start another application from Java-code,
> (like notepad.exe or invoke a document c:\mydoc.htm with my
> default-browser)
> what class/method do I use in Java?

<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#exec(java.lang.String)>
[ ..and it's overloaded variants - scroll down. ]

HTH
chris_k - 07 Nov 2005 12:45 GMT
hi,
you may use

Process proc = Runtime.getRuntime().exec("notepad.exe");

HTH,
chris
Roedy Green - 07 Nov 2005 13:43 GMT
>In windows, if I want to start another application from Java-code,
>(like notepad.exe or invoke a document c:\mydoc.htm with my
>default-browser)
>what class/method do I use in Java?

see http://mindprod.com/jgloss/exec.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Rhino - 07 Nov 2005 14:34 GMT
> Java newbie question..
>
[quoted text clipped - 5 lines]
> TIA,
> ------------------------------------------ grz01

There is an excellent article on the techniques to use - and some pitfalls
to avoid - in this article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html

The author begins by showing you basic approaches that may or may not work
very well, then gradually improves them until he has arrived at fairly
bulletproof ways of executing commands or external programs via Java.

Rhino


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.