3

A project I am currently involved in uses JavaCv/OpenCv for face detection. Since the OpenCv occasionally throws an error, and the propagation of OpenCv/C++ errors to Java Exceptions isn't fully functional yet, this means the Java main-loop crashes with no way to recover.

However, the code gives mostly accurate results, and since we're running it on a large database I baked a quick Batch-script around the execution to keep it going, and the Java code internally manages an id, to make sure it continues from just after where it crashed.

:RETRY
java -Xmx1024m -jar Main.jar
IF ERRORLEVEL 1 GOTO RETRY
EXIT 0

However, occasionally I get a Runtime Error pop-up, as follows:

Microsoft Visual C++ Runtime Library

Runtime Error!

Program: C:\Windows\System32\java.exe

This application has requested the runtime to end in an unusual way. Please contact the application's support team for more information.

At which point the code execution halts until the pop-up is clicked, which is really annoying, as it means my code can't run without me babysitting it.

I found this question, which basically asks the same thing. There is an accepted solution for that question, but since I'm not directly working with C++, I don't see how I can implement this.

Is there a Batch-level solution to this problem? Is there a Java/JavaCv-level solution to catch the C++ errors coming from OpenCv? Any other solution?

Community
  • 1
  • 1
wen
  • 3,782
  • 9
  • 34
  • 54
  • At this point I'm thinking about busting out an auto-clicker, but aside from rendering the computer useless, this would be the ugliest solution I'd ever have used. – wen Aug 08 '11 at 12:55
  • ... I am using an auto-clicker now. – wen Aug 10 '11 at 15:34

1 Answers1

1

Interesting question. Java.exe is dependent on one or more of Visual C++ DLLs (like MSVCRT.DLL, msvcr90.dll etc). Probably the JAR file is causing Java.exe to cause this error. Java.exe must be calling some CRT function which is raising the exception and hence the Runtime Error.

The best bet you can do is to launch the process, let this error pop and then start Process Explorer, and see the call stack. Nevertheless, solving this issue is most probably out of your control. May be latest version of Java may help.

Ajay
  • 18,086
  • 12
  • 59
  • 105
  • Couldn't it also be possible that the Windows implementation of OpenCv 2.3.0 is dependent on some Visual C++ DLLs? (Because this would leave me a fighting chance...) I'll take a shot at this, thanks! :) – wen Aug 09 '11 at 12:23
  • This leads me back to Java.exe. Maybe this is unsolvable? :( – wen Aug 10 '11 at 15:34
  • I am not a Java guy, so I cannot more probe into it. You may report it to Java people... – Ajay Aug 10 '11 at 15:42