File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Forking Problems

 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the subject pun.
Here's what's going on ... I'm trying to run a java task inside one of my targets, and I have the fork set to true (it's a jar), but the stupid thing won't fork.
Is there some issue regarding this?
 
Tony Yan
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be more specific. What do you mean by not forking?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, basically, it's not forking!
My build script blocks until my java task finishes (program is exited) even though I have forking enabled.
 
Tony Yan
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried some bogus ant script with forking enabled. Yes, i got what you got too. It is still a single threaded behavior. I wonder if this is normal or a bug. It is said that forking starts a new java vm to run javac. Does that mean it will be on its own Thread?
Any one got ideas?
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I understand, "fork" is intended to run a task in its own VM mainly so that if the task crashes or exits the VM, it won't crash the whole build. With this in mind, the sequencing of the build process still requires that prerequisite tasks are preformed before dependent ones, so the build has to wait for the "forked" tasks to complete.
I'm not sure the Ant build specification would even make sense if some tasks could run asynchronously. When would it make sense to run a dependent task - as soon as the asynchronous task has started? Wait for five seconds and hope it has finished? Spin checking modification times until some external resource has been updated? Something else?
On the other hand, if you really need something like this, there are plenty of examples of custom tasks which do start asynchronous processing - all the ones which start a server, for example. They don't usually use "fork", though, just run a small in-VM task which executes an external OS-level program as a background process, then immediately returns to the calling build script.
 
Tony Yan
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well said. Thanks, Frank.
 
Stanley Smith
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a sample of how I try to javac in 1.1.8 with 1.4 as my standard VM for ANT (through IDEA). If anyone knows how to ensure that the VM for the java task is 1.1.8 please share, I am having trouble getting the java command to run in 1.1.8. The help pages on ANT's java task say to set fork="true" to run in a different VM than the main ANT VM. But can't figure out to saw what VM that is.


<target name="robscompile" depends="init">
<javac srcdir="${src}"
destdir="${build}"
fork="yes"
executable="c:/jdk1.1.8/bin/javac"
compiler="javac1.1"
verbose="yes"
target="1.1"
memorymaximumsize="128m"
memoryinitialsize="128m"
/>
</target>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic