I have the following code:
ProcessBuilder pb = new ProcessBuilder( "java", "-jar", "test.jar", Integer.toString( jobId ), Integer.toString( software ), Integer.toString( entryPoint ), application );
pb.directory( new File("/home/userName/TestBSC") );
Process proc = pb.start();
When running the jar file from my terminal using this command:
java -jar test.jar 135 3 3 appName
Then it works like a charm. The box pushes some things in my database, so I see that it works. But when I do this from my JavaServlet with the above processBuilder code, I am not getting any data in my database, and I am not getting any errors either.
However, the process itself is running, I checked it with "ps ax" in my terminal. So I wonder where is the difference here? What am I doing wrong?
Does anyone have an idea?
Edit: more Code:
ProcessBuilder pb = new ProcessBuilder( "java", "-jar", "test.jar", Integer.toString( jobId ), Integer.toString( software ), Integer.toString( entryPoint ), application );
pb.directory( new File("/home/userName/TestBSC") );
Process proc = pb.start();
System.out.println( "Job running" );
proc.waitFor();
System.out.println( "Job finished" );
InputStream in = proc.getInputStream();
InputStream err = proc.getErrorStream();
byte result[] = new byte[ in.available() ];
in.read( result, 0, result.length );
System.out.println( new String( result ) );
byte error[] = new byte[ err.available() ];
err.read( error, 0, error.length );
System.out.println( new String( error ) );
UPDATE:
shell- script . script java .
script :
java -jar test.jar "$1" "$2" "$3" "$4"
, . :
gnome-terminal -x java -jar test.jar "$1" "$2" "$3" "$4"
!! gnome, jar .
, , - , eclipse? . . , , .