Supress java error output to shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Supress java error output to shell
# 1  
Old 04-27-2017
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,
Code:
"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
This User Gave Thanks to LMHmedchem For This Post:
# 2  
Old 04-27-2017
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.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 04-27-2017
Quote:
Originally Posted by jim mcnamara
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.
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
# 4  
Old 04-28-2017
There is a separate log for the java engine

try the command:

Code:
java --version

It shows some of the components as well.

And the java console for debugging small components:
Java Console, Tracing, and Logging
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to supress error message with custom text

After a bash function is run the below file is produced: out_name.txt tab-delimeted Input Errors and warnings AccNo Genesymbol Variant Reference Sequence Start Descr. Coding DNA Descr. Protein Descr. GeneSymbol Coding DNA Descr. GeneSymbol Protein Descr. Genomic... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

How to supress output from tar and unzip commands?

I have the below two commands in my script. tar -xf hello.tar unzip -o tempp.zip When i run the script i see the below on my standard out. How can i suppress output coming from both the tar and unzip on my standard output. (3 Replies)
Discussion started by: mohtashims
3 Replies

3. AIX

Unable to correct NMONVisualizer java error. Can someone help to decode this java error?

Hello AIX and Java gurus, I have a java error that I have no clue how to resolve. I am trying to run the popular NMONVisualizer utility against a NMON dataset and getting the error as shown below: /db2storage/NMON >java -jar NMONVisualizer_2015-02-02.jar com.ibm.nmon.ReportGenerator... (1 Reply)
Discussion started by: okonita
1 Replies

4. Shell Programming and Scripting

supress error messages

Hi I have a script which connects to oracle using sqlplus if ! check_sqlplus "$ORACLE_SID" ; then echo "Unable to use sqlplus for sid $ORACLE_SID" return 1 else echo "attempting to connect to database" echo $ORACLE_HOME echo $ORACLE_SID echo "Status before entering... (2 Replies)
Discussion started by: xiamin
2 Replies

5. Programming

Output to a file in java

I wanna remove element from xml file, when I run the following code I get the correct output when I'm outputing to console but when I'm trying to ouptup the same code to a file I get the same / original xml file without removed element, here is the code : import java.io.*; import... (3 Replies)
Discussion started by: c0mrade
3 Replies

6. UNIX for Advanced & Expert Users

Supress error message

Hi All this is a simple script #! /bin/bash FileCnt=`ls -lrt $DIR/* | wc -l` echo $FileCnt how could i escape the error msg if there are no files in $DIR ls: /home/sayantan/test/files/cnt/*: No such file or directory 0 Looking forward for a quick reply Regards, Newbie (2 Replies)
Discussion started by: newbie07
2 Replies

7. Shell Programming and Scripting

Supress ' quotes in a select statement inside Shell Script

Hi I have a shell script in which a string variable is saving following query. SqlQuery="select a||'|'||b||'|'||c from dual" I am trying to pass above query as a parameter to some script but its giving me error for "single quote". I tried suppressing it using \' instead of just ' but it... (1 Reply)
Discussion started by: mahabunta
1 Replies

8. Shell Programming and Scripting

How do I supress certian output with find?

I am using this command find . -type f -mmin "+$t" > holder Unfortunatley that is also printing files that begin with a period. Such as .bash_history. What can I do to supress files that begin with a period? (1 Reply)
Discussion started by: chrchcol
1 Replies

9. UNIX for Dummies Questions & Answers

lslpp output for Java package

Hi , in the process of installing HBA's(IBM 6228's) for AIX 6F1 which was recently upgdared to 5.3 ML1 after the upgrade lppchk -v output displays the following. >lppchk -v lppchk: The following filesets need to be installed or corrected to bring the system to a consistent state: ... (1 Reply)
Discussion started by: Student37
1 Replies

10. UNIX for Dummies Questions & Answers

Supress screen output...

I need to suppress the output to the screen. I am appending to a file so do not need the output on the screen in the CLI environment. eg. cat $HOME/somefile >> $HOME/anotherfile I am doing this a number of times with SQL output files so I can look at the finished file not on the screen in the... (3 Replies)
Discussion started by: jagannatha
3 Replies
Login or Register to Ask a Question