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 / March 2006

Tip: Looking for answers? Try searching our database.

fork process in Java

Thread view: 
JJ - 26 Mar 2006 18:19 GMT
Hello:

Besides Runtime.exec("executiable name"), what are the other ways to
"fork a process" in Java.

Thanks.

JJ
Roedy Green - 26 Mar 2006 19:56 GMT
>Besides Runtime.exec("executiable name"), what are the other ways to
>"fork a process" in Java.

you can start a Thread which is internal to the JVM.

That's it as far as I know. Anything else would be platform specific
and require JNI.
Signature

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

Peter Jones - 26 Mar 2006 22:17 GMT
> Hello:
>
[quoted text clipped - 4 lines]
>
> JJ
As far as I'm aware, you "fork" a process by using threads. You'ld have to
Google it more though, thats as far as I know. Hope it helps
Wibble - 27 Mar 2006 02:58 GMT
>>Hello:
>>
[quoted text clipped - 7 lines]
> As far as I'm aware, you "fork" a process by using threads. You'ld have to
> Google it more though, thats as far as I know. Hope it helps
A thread isn't a processess.  The only way other
than Runtime.exec is to write JNI code (java native interface).

You probably dont really want to fork a process, right?
Thomas Weidenfeller - 27 Mar 2006 08:41 GMT
> Besides Runtime.exec("executiable name"), what are the other ways to
> "fork a process" in Java.

The almost unknown java.lang.ProcessBuilder

Don't ask me why Sun added this in 1.5.

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

tom fredriksen - 27 Mar 2006 14:45 GMT
> Hello:
>
> Besides Runtime.exec("executiable name"), what are the other ways to
> "fork a process" in Java.

AFAIK, there is no fork concept in java, thats a unix thing. The only
concepts available are starting a new application (exec) and starting
new threads. There might be some library that have implemented fork etc
through jni (I know there is for posix pipes, shared memory etc.), that
would give you almost the full power of fork and the unix process
concept. But sadly its not supported in java.

/tom
Thomas Hawtin - 27 Mar 2006 17:14 GMT
> AFAIK, there is no fork concept in java, thats a unix thing. The only
> concepts available are starting a new application (exec) and starting
> new threads. There might be some library that have implemented fork etc
> through jni (I know there is for posix pipes, shared memory etc.), that
> would give you almost the full power of fork and the unix process
> concept. But sadly its not supported in java.

Indeed, Windows creates new processes rather than forks (although
presumably it can do some kind of fudged fork for POSIX). I don't like
the chances of the JRE keeping it together if you try to use it from
both legs.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

James McGill - 27 Mar 2006 18:45 GMT
> AFAIK, there is no fork concept in java, thats a unix thing.

A fork() would amount to a copy of the JVM.  I get no further than that
when I realize it's too complicated to even think about.


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.