Check status code (e.g. - System.exit(1) ) in Unix

Posted on 2003-03-28
Medium Priority
Last Modified: 2010-08-05
Do you have any idea how to check the Java status code returned from System.exit(int status) in Unix?

In DOS I was able to write this:

java -jar FilePreparation.jar
if not %errorlevel% == 0 goto file_prep_err

But I can't find anything equivalent for Unix?
Question by:jjungman
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 8227562
in bash you can use $? to get the exit status of the previous command.


Accepted Solution

wide_awake earned 300 total points
ID: 8227595
for example, put this into "test.sh"
java -jar FilePreparation.jar
echo $?

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question