Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How would i do these things??

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How would i do these things??

    Ok ive used this sites search engine, been on other sites but i can never get the info im looking, for please help;

    i) Ok theres this game, upon creating a server for the game, you are provided with a command prompt window as displayed below, this acts as a console where u can type commands to adjust the server variables and events taking place on the server (in game) are displayed, my question is how could i (instead of typing) get my java program to 'print' strings in this window?

    Click image for enlarged view

    ii) With regards to the same command prompt window, how would I read lines from this window into my program?

    iii) In the context of the above command prompt window, how would i make my program constantly monitor the command prompt window and process each new line of text as it appears, almost like a listener but for the occurence of text?

    iv) Can java programs only be compiled to .exe's using specialized software? If so what is the best free software i can aquire to do this?

    Your help and answers would be greatly appreciated

    *Warning there very well might be follow up questions to the above, i only just matriculated, that combined with a little further exploration of java coding is the limit of my experience and knowledge


  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How would i do these things??

    Sorry wasnt i clear or did i not provide enough info?
    just the inputing from and outputing to that command box is the main info or task i need help with

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: How would i do these things??

    One thing you can try is to redirect all output via the command console to your java program:

    (in the commandline)
    some_program.exe >> javax some_java_program

    I believe this will set some_java_program's input stream to come from some_program.exe.

    You can compile Java programs to .exe files via some external program, but then the would only run under windows. The preferred method is archive your java program into an executable jar file (see here[/b]).
    The Eclipse and NetBeans IDE's (and probably some others) also come with the ability to export to executable jar without having to use the command line.

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How would i do these things??

    Ah thank you so much, ill definately try that and get back to you =)

  5. #5
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: How would i do these things??

    If you were to get your Java program to launch the console game, then it could open input and ouput pipes with the console so that you can monitor everything that happens and write out to it.

    Regards,
    Chris

Similar Threads

  1. Java is resetting my variables to zero, and other mysterious things
    By schcrosby in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 12th, 2010, 09:50 PM
  2. [SOLVED] Prime number generator program in Java
    By big_c in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 27th, 2009, 12:08 PM