views:

29

answers:

1

I have a program I made in C that will restart my Java application after running for 2 hours.

First of all, I run my java program using a batch file,

@echo off
java -server -Xmx1024m -Xbootclasspath/p:"bin;" website.Server >>C:\web_logs\console.log

It works perfectly fine, but after the 2 hours is up I use Runtime.getRuntime(); in Java for a clean prepared restart; to execute my C program "Restarter.exe". Restart.exe kills the java process and also kills the cmd process (I killed the command process because I wasn't sure why it keeps saying "...process cannot access the file... used by another process."

And it works just fine if I don't use the windows logging ">>" after my arguments.

It's just when I try to log the console, it doesn't restart. I have a lot of debug going on in the console and the windows command prompt can only remember so much. So I used ">>" to log to a file and read it later. I don't want to log a file via java because it's something I don't need to do if I'm using a windows computer.

So my question is, how can I still log the console using ">>" after my arguments so it still restarts? It keeps saying the process is being used but I thought I killed it by killing java and cmd? What can I do to fix that or end the process so I can parse the same file?

Thanks.

+2  A: 

I recommend installing Process Explorer, and when you get that error message, use the "Find Handle" feature and see what process is holding a handle to that file.

Post back!

The Alchemist
I tried doing this and I'm not sure what I'm doing wrong, but after it says it's being used by another process it immediately terminates I'm not sure how to track it:\
Kyle