Editor with built-in compiler?

Discussion in 'Mac Programming' started by pixelbaker, Feb 20, 2008.

  1. macrumors member

    pixelbaker

    Joined:
    Aug 21, 2006
    #1
    I'm in an application development class learning the very basics of java. I've been using TextMate for my coding purposes, but now my simple apps need to be able to request input in a command line form and then return results based on it.

    I can compile and run, but it won't request that info and then keep running.

    Somebody said that I need to just run it through the command line and I was hoping to do that, but I'm not really sure how. I also compile quite often and it would be nice to have a shortcut key to do it

    Is there some other editor that has this functionality? I don't mind Eclipse/NetBeans/XCode but they seem like overkill for the stuff I'm doing.

    Thanks in advance
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Just use the Terminal to execute your program. You will obviously need to write your program to take input from the standard input and the write and information you need back to the standard output. If you are having problems with the program not continuing to run then you need to rethink how you have written your program.

    Not sure how to do it in Java but it should be similar to C.
     
  3. thread starter macrumors member

    pixelbaker

    Joined:
    Aug 21, 2006
    #3
    :( my problem is that I don't know how to execute it it the Terminal. and I would like to be able to somehow compile and execute in the terminal with a keyboard shortcut from my text editor eventually.
     
  4. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #4
    To execute a java app in Terminal, just be sure you are in the folder where the .class file exists, for example, mytest.class, and then type

    java mytest

    That's pretty much all there is to it, from a basics standpoint.

    Todd
     
  5. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #5
    And, after you type the javac command once, and the java mytest command once, you can use the command stack in Terminal (you can recall previously entered commands) by using the up and down arrow keys.

    It's pretty fast.

    Todd
     
  6. macrumors 6502

    Joined:
    Apr 9, 2006
    Location:
    Boston, MA
    #6
    if you can compile and run it, but don't get an input prompt, it sounds like your reader is messed up, here is my example code to do that
    Code:
    BufferedReader in = new BufferedReader( new InputStreamReader(System.in) );
    System.out.printf("Enter some text: ");
    String message = in.readLine();
    and just use the normal javac and java to compile and run the program from the terminal.

    P.S. JJEdit looks perfect for what you are doing.
    P.P.S. it seems to have the same bug that netBeans has when requesting info, doesn't display the text of what you should input first, plus various other annoyances.
     
  7. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #7

Share This Page