-1

first see this image:window

To understand my question you have to see the image first. So, I have made a program in netbeans(java) which can convert simple and easy codes ( like: Print "sum") into actual java codes (i.e. System.out.print("sum");). Now what I want to do is create a button in the window marked a (1) that is RUN, which when clicked will show a new window like the bluej output box terminal marked as (2) in the image which will show the ouput of the generated code like what is shown in bluej after compiling it. Using this students will be able to instantly type codes and see the output of their programs very fast.

 private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // I want to know what code should i put here that will return the ouput.
}

for more info visit my website: http://fdti.weebly.com

Rohit
  • 1
  • 2
  • Have you tried anything yourself? – Matthew Jan 10 '16 at 07:49
  • You can dynamically compile, load and run (a) class(es) using something like [this](http://stackoverflow.com/questions/21544446/how-do-you-dynamically-compile-and-load-external-java-classes/21544850#21544850) – MadProgrammer Jan 10 '16 at 08:11
  • You can redirect System.out.println to a JTextArea using something like [this](http://stackoverflow.com/questions/12945537/how-to-set-output-stream-to-textarea/12945678#12945678) – MadProgrammer Jan 10 '16 at 08:14
  • Now getting user input is a little bit more difficult, but perhaps you could use something like [this](http://stackoverflow.com/questions/15017148/jtextarea-as-io-console/15025085#15025085) as a starting point – MadProgrammer Jan 10 '16 at 08:16

1 Answers1

0

Use processBuilder to launch a terminal, and execute java code.

mohitm
  • 153
  • 10