2

I am trying to make my own Java IDE, however i am having problems getting the input from user after displaying the program itself

I have so far tried 2 ways of getting the console to appear. Using Create Java console inside a GUI panel

or using my own code of

void runCommand(String command)
{
    try {
        ProcessBuilder builder = new ProcessBuilder(
                "cmd.exe", "/c", command);
        builder.redirectErrorStream(true);
        Process p = builder.start();
        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line;
        while (true) {
            line = r.readLine();
            if (line == null) { break; }
            System.out.println(line);
        }
    } catch (IOException ex) {
        Logger.getLogger(FileToClass2.class.getName()).log(Level.SEVERE, null, ex);
    }


}

void createClass(String dir, String filename)
{
    //TODO: stop using exact java path / compile all .java in a dir
    runCommand("cd "+dir+" && \"C:\\Program Files\\Java\\jdk1.8.0_91\\bin\\javac\" " + filename);
}

void runClass(String dir, String filename)
{
    //TODO: allow use of packages etc
    runCommand("cd " + dir + " && java " + filename);
}

This above code simply gets the output of the cmd terminal, the problem both these approaches have is the lack of input say if the user wanted to do a Scanner nextLine() Is there any solution to this?

Community
  • 1
  • 1
Froodle
  • 339
  • 2
  • 5
  • 15

0 Answers0