execute command unix with java:possible or not?

hi everybody,
i have a small unix script and i want to use it with java, so how can i executte unix command with java (if it is possible): in fact i want to use some values returned by this script with java swings.
is it possible (of course everything is possible) but how can i do? thank you in advance for your help.

what language is the script written in? if its written in java you can run it with java. if its written in bash you can run it with bash...am i understanding your question correctly?

See JDK 19 Documentation - Home

hi,
norsk hedensk my script is in bash , for example this one:

#!/bin/bash
echo "hello"

i want to know if it s possible to run it with a program java? I think that could be

It's fairly easy to execute a command that's in your PATH, for example, ls

import java.io.InputStream;
import java.io.IOException;

public class foo
{
   public foo()
   {
       Runtime rt = Runtime.getRuntime();
       Process p = null;
       try
       {
           p = rt.exec( "ls -l" );
       }
       catch ( IOException ioe )
       {
           System.out.println( "Error executing file" );
       }
       InputStream output = p.getInputStream();
       System.out.println( output );
   }

   public static void main( String args[] )
   {
       foo f = new foo();
       System.exit( 0 );
   }
}

Scripts are a little more work, have a look here

that should help.

Peace,
ZB
http://www.zazzybob.com

EDIT: My code worked for commands, not scripts. Hay ho.