Supress java error output to shell

Hello,

I know this isn't exactly a shell script question but I'm not sure where else to post it.

I am running a java program out of a shell script. There are times when I get an error like,

"java.lang.ArrayIndexOutOfBoundsException: 22
        at blah, blah
        at blah, blah
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)"
java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 22
        at blah, blah
        at blah, blah
Caused by: java.lang.ArrayIndexOutOfBoundsException: 22
        at blah, blah
        at blah, blah
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)

The error above isn't import in and of itself. I have a work around when this happens but I would like to get rid of the error printing to the shell.

I am calling the program with,

java_app --log-level off -o output_file input_file ... other_options ... 2> /dev/null

I thought that the 2> /dev/null would dump the error printout, but I am still getting it. The --log-level off was an attempt to limit output from the program but the error messages look like they are from the jre and not the application.

Any suggestions on how to clean this up?

---------- Post updated 04-27-17 at 01:02 PM ---------- Previous update was 04-26-17 at 11:12 PM ----------

This actually does work,

java_app --log-level off -o output_file input_file ... other_options ... 2> /dev/null

which, really, it has to. For some reason it wasn't working and now it is???

I was thinking it wasn't working because the errors were from the jre and not the application, but at any rate, the error output is gone now.

LMHmedchem

1 Like

Writing to stderr is dependent on the environment of the process doing the actual write() call. A child process may possibly have a different view of what the #2 file descriptor points to.

1 Like

Thanks for the input. If the errors return, I guess I will have to look into it a bit more. I actually don't think I need any of the output to the terminal because I am specifying an output file in the call. I could probably just redirect everything to /dev/null.

LMHmedchem

There is a separate log for the java engine

try the command:

java --version

It shows some of the components as well.

And the java console for debugging small components:
Java Console, Tracing, and Logging