I guess what I'm asking is....

Discussion in 'Java' started by Ashanen, Jan 2, 2004.

  1. Ashanen

    Ashanen Guest

    ....the simplest way to have a very small Java program (eg "hello world")
    actually entered in a text area, and when an " execute button" is pressed, it
    will actually execute it as a program.

    At present I am using that the tasks for the button would have to include
    saving the text area contents as a Java file, then calling a dos process
    somehow to compile and execute it. But I am unclear on how to do that (get it
    to call the DOS process). Or even whether this is the simplest way of doing
    this!
     
    Ashanen, Jan 2, 2004
    #1
    1. Advertising

  2. Ashanen

    KC Wong Guest

    > ...the simplest way to have a very small Java program (eg "hello world")
    > actually entered in a text area, and when an " execute button" is pressed,

    it
    > will actually execute it as a program.
    >
    > At present I am using that the tasks for the button would have to include
    > saving the text area contents as a Java file, then calling a dos process
    > somehow to compile and execute it. But I am unclear on how to do that (get

    it
    > to call the DOS process). Or even whether this is the simplest way of

    doing
    > this!


    That is already done and available for free...
    Visit http://www.beanshell.org/ and see for yourself.
     
    KC Wong, Jan 2, 2004
    #2
    1. Advertising

  3. On 02 Jan 2004 03:30:51 GMT, (Ashanen) wrote:

    >...the simplest way to have a very small Java program (eg "hello world")
    >actually entered in a text area, and when an " execute button" is pressed, it
    >will actually execute it as a program.
    >
    >At present I am using that the tasks for the button would have to include
    >saving the text area contents as a Java file, then calling a dos process
    >somehow to compile and execute it. But I am unclear on how to do that (get it
    >to call the DOS process). Or even whether this is the simplest way of doing
    >this!


    Servlet engines are essentially doing this: going through the
    compile-execute process and running the code. If you are really doing
    "Hello, world!" kind of text-based stuff, that's a way to do it.

    --phil
     
    Phil Earnhardt, Jan 2, 2004
    #3
  4. "Ashanen" <> wrote in message
    news:...
    > ...the simplest way to have a very small Java program (eg "hello world")
    > actually entered in a text area, and when an " execute button" is pressed,

    it
    > will actually execute it as a program.


    to compile it start here..
    http://groups.google.com/groups?threadm=7khegn$63k$
     
    Andrew Thompson, Jan 2, 2004
    #4
  5. Ashanen

    Ashanen Guest

    Is there a simple way go call a dos process or get a windows bat file to
    execute by an instruction in the event handler for a JButton?
     
    Ashanen, Jan 2, 2004
    #5
  6. Ashanen wrote:

    > Is there a simple way go call a dos process or get a windows bat file to
    > execute by an instruction in the event handler for a JButton?


    Yes, use something like this :

    import Java.lang.*;
    import Java.io.*;

    public class RuntimeExecTest {
    public static void main(String[] args) {
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = { "Notepad.exe",
    "D:\\TEMP\\Test.txt" };
    try {
    Process child = rt.exec(callAndArgs);
    child.waitFor();
    System.out.println("Process exit code is:
    " + child.exitValue());
    }
    catch(IOException e) {
    System.err.println(
    "IOException starting process!");
    }
    catch(InterruptedException e) {
    System.err.println(
    "Interrupted waiting for process!");
    }
    }
    }

    Hope this helps you further, brgds Herman
    --
    Suse Linux Professional 8.1 on Athlon 1.1 Ghz 512 Mb
    Anti Spam = remove the "dot" and the "at"
    Registered Linux User #264690
    Visit us : http://users.skynet.be/herman.timmermans
     
    Herman Timmermans, Jan 2, 2004
    #6
  7. Ashanen

    Ashanen Guest

    Herman

    Thank you for that information
     
    Ashanen, Jan 3, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    5,587
  2. Jim in Arizona

    Guess What ...

    Jim in Arizona, Jan 31, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    463
    Juan T. Llibre
    Jan 31, 2006
  3. JavaJunkie
    Replies:
    12
    Views:
    905
    JavaJunkie
    Feb 4, 2004
  4. Michael Wurm
    Replies:
    12
    Views:
    597
    Roedy Green
    Jul 23, 2004
  5. Ramon F Herrera

    I guess I have to wait();

    Ramon F Herrera, Jan 17, 2005, in forum: Java
    Replies:
    7
    Views:
    369
Loading...

Share This Page