Process.waitforexit java


process.waitforexit java

The purpose of this code is run an IFilter extract on a document, we use a seperate process because some IFilters are notoriously flaky. Now this code runs perfectly fine on Java 7 and Server R2 boxes but on a Windows Server the WaitForExit immediately throws a "There is java process associated with this Process object" exception. The process does exist and completes its task without a problem. If Java place this code in a Console App and run it works fine on the Windws Server box as well, hence it would appear to be a specific problem running this in a Service on a Windows Server box.

When starting processes, with the System. Process class, the system can either use CreateProcess or ShellExecuteEx Win32 function. When using CreateProcess only executable files can be started. However these are completely different ways of starting processes. This may involve for example using DDE to search for and then activate an existing Excel instance. Note that ShellExecuteEx may or may not return an hProcess depending on whether a new process was started.

This is the behavior which you are seeing. CreateProcess is a lower-level function and creates a process directly, and simply passes the equivalent arguments. It always returns a process handle. Since you seem to be starting an executable file, it is a bit surprising that no hProcess is returned by ShellExecuteEx.

By posting your answer, you agree to the privacy policy and terms of service. Stack Overflow Process.waitforexit Search Jobs Documentation beta Tags Users. Sign up or log in to customize your list. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.

Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7. Join them; it only takes a minute: I have a windows service containing this code: Close ; if exitCode! Can anyone shed any light on why WaitForExit would thow this error? Additional Info If I place this code in a Console App and run it works fine on the Windws Server box as well, hence it would appear to be a specific problem running this in process.waitforexit Service on a Windows Server box.

AnthonyWJones k 24 That's very hard to explain with this code. Tinker with the service settings. Make sure the "interact with desktop" option is turned off. Post anything you find in the Application event log. The error occurs when you don't get a HANDLE to the process hence cannot wait for it. Also process.waitforexit you describe the bitness 32 vs 64 of the service vs. Finally try Process Monitor and see what it shows happening. Nothing is appearing any of the event process.waitforexit at least nothing that my code is not deliberately putting there.

I'm not sure where to find the "interact with desktop" option"? Bitness is a good point. The Windows server is a 32 bit server so both service and executable run as 32 bit. However the Windows 7 ans R2 machines are 64 bit and both service and executable run as 64 bit. Java it could be this is the difference not the OS version. Post your "UseShellExecute" suggestion as an answer because that does fix this problem. Sign up or log in StackExchange.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Stack Overflow works best with JavaScript enabled. MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3.

Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

Difference between process and thread ?

Difference between process and thread ? process.waitforexit java

3 thoughts on “Process.waitforexit java”

  1. alseverov says:

    My name is Keith and I am with the HIV Reference Laboratory here in the Bahamas and would like to know if you have heard are any online PhD programs where the thesis can be completed at ones own lab.

  2. Akonit says:

    Quick Reports allows users to create a new type of grid-based GUI report with grouping, aggregation, charts, titles, fonts, and standard text formatting.

  3. Adeljan says:

    When approaching the idea, many people would like to believe that five day school weeks are the most efficient and productive way to educate our youth.

Leave a Reply

Your email address will not be published. Required fields are marked *