make a simple java program that runs command prompt commands from the java program somewhat similar to jCreator

I am trying to make a simple java program that runs command prompt commands from the java program somewhat similar to jCreator.in here I only wanted to compile and run the relavant main class.

this is my code.but this don't work properly.But with out asking for keyboard input program runs properly. please give me some help.

my code is

   import java.io.*;

public class A {

  private static void printLines(String name, InputStream ins) throws Exception {
    String line = null;
    BufferedReader in = new BufferedReader(
        new InputStreamReader(ins));
    while ((line = in.readLine()) != null) {
        System.out.println(line);
    }
  }

  private static void runProcess(String command) throws Exception {
    Process pro = Runtime.getRuntime().exec(command);
    printLines(command + " stdout:", pro.getInputStream());
    printLines(command + " stderr:", pro.getErrorStream());
    pro.waitFor();

  }

  public static void main(String[] args) {
    try {
      runProcess("javac Main.java");
      runProcess("java Main");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

my main class is

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    int x = input.nextInt();

    System.out.println(x); 

    System.out.println("s");

    System.out.println("ok");

  }
}

Answers


Need Your Help

custom font-face looks bad only in firefox

css firefox font-face

I am using the Noto Sans Hebrew font-face from google's early access webfonts. And as usual, there's a rendering problem on windows.

C++ odd template issue

c++ templates

I have this class with a nested type, in order to allow class templates share a static mutex:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.