mardi 21 avril 2015

how to run scala jar file within java file?

Ineed to run scala jar file from java code :

so if I had this scala code:

 object test extends App{
   override def main(args: Array[String]) {
      println("Hello, world! " + args.toList)

and i exported in demo.jar , i want to exceute from inside java application? the way im using it is throw runtime process which not working with me?



public class testscalajar{

    public static void main(String[] args) {
        // TODO Auto-generated method stub
            Process proc = Runtime.getRuntime().exec(new String[]{"scala","-cp","d:\\demo.jar", "test"});
         // Then retreive the process output

         InputStream in = proc.getInputStream();
         InputStream err = proc.getErrorStream();
         String inString = IOUtils.toString(in, "UTF8"); 
         String errString = IOUtils.toString(err, "UTF8"); 
            catch ( Exception e)



any body have any other solutions?????

Aucun commentaire:

Enregistrer un commentaire