I have a jar say test.jar having TestJar as its main class, a shell script jar\_executor.sh,and a java file. My test.jar will return 1 if we pass 1 as an argument and 2 if we pass any other value.
My shell script is executing test.jar as follow

```
#!/usr/bin/ksh
java TestJar 1 -cp test.jar
return_code=$?
exit $return_code 

```

In java file I am creating a process and executing shell script and taking its exitvalue with following code

```
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(sh jar_executor.sh);
int exitVal = process.waitFor();
System.out.println(exitVal);

```

This exitVal variable should print 1 or 2 as per argument we are passing but it is printing 255 everytime.
If I use `echo $return_code` in shell script then I am getting correct value.
Please help me why I am getting value 255 with `exit`. Thanks in advance!!!