Script Shell in java code

Hello,

This is my script shell:

echo Mon premier script
echo Liste des fichiers :
ls -la
 
exit 0

This is my code java:

public class test {
 
	public static void main(String[] args) {
		try {
			Process process = Runtime.getRuntime().exec("sh script1.sh");
			
			

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

But no display! have you an idea?

Thank you

You're executing a command as a separate process. This process has its own input and output streams and java wont just display its output for you automatically. You still need to query it for its input stream and then write that back to standard out yourself.

Take a look into BufferedReader, InputStreamReader and the getInputStream method that Process objects have.

Thank you so much
Please i want to pass parameter (the string s) to the shell script:

How can i do please?
Thank you