Command line program: can it implement keyListener??

Hello,
before I take the trouble to learn keyListener implementation, I am wondering if my program could even implement it. It is just a small game that just plays in the command window. I would like it to respond to the user pressing up, down, left and right keys. Is this possible with a keyListener or is this only possible in a 'windowed' application?
And if you cannot register keys this way from the command line, then how would I make my program interactive. Do you know a link to an API description that explains how to set the program up to give a prompt?
Thank you very much!
-Mike.

guess not...

Similar Messages

  • Javac command line program can use class, need tomcat to do same

    This may be simple, but any assistance to a newby would be greatly aprreciated. I have a this class file:
    import java.io.*;
    public class OCrypt
    static public String getEncryptedText (String plainText)
    Runtime R;
    String _encryptedText = "";
    char[] someData = new char[16];
    R = java.lang.Runtime.getRuntime();
    try
    java.lang.Process P = R.exec("./OCrypt " + plainText
    InputStreamReader ISR = new InputStreamReader(P.getInputStream());
    ISR.read(someData);
    _encryptedText = new String(someData,0,11);
    catch (Exception e)
    _encryptedText = "***ERROR***";
    return (_encryptedText);
    Where ./OCrypt is a compiled program writtine in C in the same folder. A small test program calls the class and C code and works. Now for the tomcat part, I need to be able to call this code from tomcat. I know it has worked in the past on a much older version of tomcat. I need to figure out how to make it work on tomcat 5.5.9
    Thanks

    Thanks for the reply. Please bare with me. I am reading in the SAMS teach yourself book to know how to create the folder structure. I assumed this folder should be off of my WEB-INF/classes folder. See the full path below.
    Couple of things
    1 - Your class should be in a package. Otherwise you
    will have problems.I added the .class file to a package. Or at least I think I did. I added this line to the top of the code.
    package OCrypt;
    The file is in this folder:
    /var/local/jakarta-tomcat-5.5.9/webapps/ROOT/pss/WEB-INF/classes/OCrypt
    Then I ran 'javac OCrypt' in that folder.
    2 -
    Where ./OCrypt is a compiled program writtine in C
    I always keep the C file in the same location as the class. That may be a problem later when tomcat can resolve the class but then can't find that program. I hope that will generate a completely different error.
    in the same folder.
    In the same folder as what?
    The current working directory for Tomcat is normally
    [TOMCAT]/bin. Is that the folder you mean? I will put it there if I get the class resolved.
    If you want to use this tool, I would say put it in
    the PATH for the machine (so it can be found from
    anywhere) or use an absolute reference to it.I can put a complete path in the .java file before I compile if you think that will help.
    You> can't count on the working directory being where you
    think it is. But right now I would just like to create a simple class like adding two numbers together and returning a result. My larger issue is more of a server configuration. I am using a enterprise wide tomcat server and have been told EACH application folder has it's own classpath. I even attempted to write a JSP that would output my enviroment to a simple page. This didn't work because the env was only for the user, not the env AFTER all the startup scripts run for the server.
    >
    One solution is to use ServletContext.getRealPath().
    Is there any reason you couldn't rewrite the
    encryption into Java - that way you wouldn't have to
    bother with Runtime.exec()
    Another alternative would be to use JNI to get a Java
    interface to the C class.
    http://www-128.ibm.com/developerworks/edu/j-dw-javajni
    -i.html
    I think either of those solutions are preferable to
    using Runtime.exec().

  • Creating a command line program reading AEP/AEPX files?

    I'm new with After Effects SDK, and I wanted to know if it's possible to use SDK to implement a command line program that gets information such as duration and frame rate in AEP/AEPX files.
    aerender, a command line render program provided by After Effects, prints out these information before rendering. But it doesn't seem to be able to print out the information without doing rendering.
    I saw a related thread here: http://forums.adobe.com/thread/844341
    But what I want is simpler. I don't need to alter the AEP/AEPX files. I just want to obtain the information quickly from an AEP/AEPX file. Is it possible to write such a tool using SDK?
    Thanks!

    hi eliang.cs!
    yes, i'm the same guy who answered on the other thread.
    everything the API does, it does through AE as a plug-in.
    so if you have AE running (even just the renderer), your project loaded and your plug-in present, you can access all the data you described with no problem, and export it out in whatever way you want. (a plug-in is actually a DLL, so you can do anything you want, even on an OS level)
    you can access the data on all elements of the project including comps, layers, footage, render queue, ect...
    having said that, you can do all of this using a script instead of a plug-in.
    scripts are much easier to build.
    perhaps there's even a script out there that does what you're looking for, or something very close that could easily be adjusted.

  • Is there a command line program that converts WAV to SWF?

    Is there a command line program that converts WAV to SWF?
    thanks

    why you want to do that? you can import your wav into the
    swf!

  • Fast command-line program which displays connectivity

    Hi
    I'm looking for a command-line program which can show whether or not my network interface has an IP address or not. It could use "ifconfig" to extract the information, I don't really care, but it has to be *fast* and it cannot require root access.
    Thanks

    Thanks, but if someone knows some sed/awk magic to get only the interface's IP address, that would be great!
    EDIT:
    Using the little "sed" I know, this is what I came up with:
    ifconfig wlan0 | grep -w inet | sed "s/^\\s*//" | sed "s/^inet addr://" | sed "s/\\s.*//"
    EDIT2:
    Now I have this reasonable command:
    ifconfig wlan0 | grep -w inet | sed "s/.*inet addr:\([^ ]*\).*.*/\1/"
    Last edited by skorpan (2009-06-07 16:44:19)

  • Tagging command line programs in subtle?

    I'd like to be able to tag command line programs so I can assign them to specific views and gravities within those views.
    For example, I'd like to be able to have 'gclacli calm' be recognized by a tag so it appears in my 'agenda' view and assign it a gravity. Is there a way to do this? Right now the best I can do is limit xterm to different views but they still move around when I change  views.
    Last edited by tinySpark (2012-06-14 18:04:12)

    None of these options have worked.
    for the user variables, i just create a new one called "Path" and type in my path to java \bin right?
    This is quite frustrating. Thanks for the help though!
    --Brenton                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Uninstalling Command Line Programs

    I've searched these forums and the internet for an answer to this, but there doesn't seem to be anything out there, so I hope this will be helpful to others as well.
    I have some open source command line programs that I downloaded, compiled, and installed as part of some exercises I was doing in a book on open source GIS (geographic information systems). What I want to know is how do I remove those programs? I can find references for compiling and installing these types of programs all over the internet, but nothing about removing or uninstalling them.
    Also, any ideas for good, up-to-date references on learning Unix in Mac OS X would be appreciated too. I'd like to get more into open source GIS, but from the research I've been doing, knowing Unix would help a lot.

    What process did you use to compile and install? Was it a configure, make, make install sequence, which is fairly common? If so, go back to the directory where you did that, and try, for example, 'make uninstall'. This might work.
    Look for output files from the compile and install process (perhaps config.log) that might tell you where files will be installed. Perhaps in /usr/local?
    Is there a README or INSTALL file that came with the source code? Documentation about what was installed where might be there.
    If worst comes to worst, and you're really determined, you could repeat the compile and install steps, but with a before and after listing of all the files in your system, and compare the listings. Or use the find command immediately after the reinstall, looking for recently created or changed files (the 'mtime' option or similar).

  • Cope: a command-line program colouriser

    cope is a wrapper around various command-line programs that takes their output and adds colours - a sort of ornamental cope, if you will.
    It's written in Perl, and requires version >= 5.10, so installation may be a bit complicated if you have to track down the dependencies. It installs several scripts in a directory, each one calling the program it's named after, only highlighting its output using regexes. Then you add this directory to your $PATH, and everything should (hopefully!) be seamless.
    Currently it's in release candidate status - I've been using it personally for a few weeks and nothing catastrophic has happened so far, so there's little point me keeping it private.
    Screenshots:
    Main site: http://stuff.cytzol.org/cope/
    GitHub: http://github.com/cytzol/cope

    PKGBUILD
    # Contributor: denton <e9203.00 gmail com>
    pkgname=cope-git
    pkgver=20091208
    pkgrel=1
    pkgdesc='A colourful wrapper for terminal programs'
    arch=(any)
    url=http://stuff.cytzol.org/cope/
    license=('GPL' 'PerlArtistic')
    depends=("perl>=5.10")
    makedepends=(git)
    provides=(cope)
    conflicts=(cope)
    install=$pkgname.install
    _gitroot=git://github.com/cytzol/cope.git
    _gitname=cope
    build() {
    cd $srcdir
    # Git
    msg 'Connecting to Git server...'
    if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin || return 1
    msg 'The local files are updated.'
    else
    git clone $_gitroot || return 1
    fi
    msg 'Git checkout done or server timeout.'
    msg 'Starting make...'
    rm -rf $srcdir/$_gitname-build
    git clone $srcdir/$_gitname $srcdir/$_gitname-build || return 1
    cd $srcdir/$_gitname-build
    # Build
    PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
    make || return 1
    make install DESTDIR=$pkgdir || return 1
    # Remove perllocal.pod and .packlist
    find $pkgdir -name perllocal.pod -delete
    find $pkgdir -name .packlist -delete
    cope-git.install
    post_install() {
    echo 'Prepend /usr/share/perl5/vendor_perl/auto/share/dist/Cope/ to $PATH'
    post_upgrade() {
    post_install
    First time making a perl package. It puts files that shouldn't be in */site:
    /usr/bin/perlbin/site/envpath
    /usr/lib/perl5/site_perl/5.10.1/IO/Pty.pm
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty.pm
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty/
    /usr/lib/perl5/site_perl/5.10.1/IO/Tty/Constant.pm
    /usr/lib/perl5/site_perl/5.10.1/List/MoreUtils.pm
    /usr/lib/perl5/site_perl/5.10.1/Params/Util.pm
    /usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/IO/Tty/Tty.so
    /usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/List/MoreUtils/MoreUtils.so
    /usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.bs
    /usr/lib/perl5/site_perl/5.10.1/auto/Params/Util/Util.so
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector.pm
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector/
    /usr/share/perl5/site_perl/5.10.1/Class/Inspector/Functions.pm
    /usr/share/perl5/site_perl/5.10.1/Env/Path.pm
    /usr/share/perl5/site_perl/5.10.1/IO/Stty.pm
    /usr/share/perl5/site_perl/5.10.1/IO/stty.pl
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/CC.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/SEN.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1035.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1738.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC1808.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2384.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2396.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/RFC2806.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/fax.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/file.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/ftp.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/gopher.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/http.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/news.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/pop.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/prospero.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tel.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/telnet.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/tv.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/URI/wais.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/_support.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/balanced.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/comment.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/delimited.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/lingua.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/list.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/net.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/number.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/profanity.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/whitespace.pm
    /usr/share/perl5/site_perl/5.10.1/Regexp/Common/zip.pm
    And as shown by the previous list, I haven't fetched these binaries (are they in the repos?):
    Env::Path
    File::ShareDir
    IO::Handle
    IO::Pty
    IO::Stty
    List::MoreUtils
    Regexp::Common
    Term::ANSIColor
    Everything works, except cope_path.pl.
    Last edited by denton (2009-12-08 09:14:37)

  • Setting column width in a command-line program

    Is there a way to send data to the screen in a command-line Java program that will be formatted as a number
    of columns with a set column width? I am looking for something similar to the C++ setw() I/O manipulator
    used in cout.
    Thanks,
    Steve

    If you go to: http://java.sun.com/docs/books/tutorial/essential/io/writingFiltered.html
    it will show you how to subclass a filtered output stream and add your own formatting methods.Then you can chain your new class to System.out
    like this:
    YourFilteredStream yfs = new YourFilteredStream(System.out); .
    Then:
    yfs.yourNewMethod(); goes directly to system out in the new format.

  • Command line program execution problem.

    Hey there, I'm about to complete my Java thesis project, but I can't fix a problem: i have to find a command line programme (which is in python but i think its not a big deal) through a java programme. Getting some information around I ended up i could execute the program with the command:
    Process proc = Runtime.getRuntime().exec("...");
    and create the streams:
    OutputStream out = proc.getOutputS 14.49
    InputStream in = proc.getInputStream();
    the problem is that calling a programme which prints on screen something and then it ends (ex. ipconfig) the following sequence works out:
    do
    int i=in.read();
    if(i==-1) break;
    System.out.print((char)i);
    }while(true);
    instead in the specific case of the programme that i need to execute it canno't work because this programme after its opening prints a couple of lines, at this stage you need to type the input in and when the eof font is sent the output is printed. i've tried to send the input thru OutputStream but the execution gets stuck when it reads the output (in.read());
    Can you guys help me out? What do i need to do? Please it's very important, let me know ASAP.
    Thanks very much,
    Fabio

    I would not recommend the use of raw "InputStream" for much of anything.
    Try Scanner if you can use JDK5, if not, try BufferedReader.
    Scanner:
    Process proc = Runtime.getRuntime().exec("...");
    BufferedOutputStream out = new BufferedOutputStream(proc.getOutputStream());
    Scanner in = new Scanner(proc.getInputStream());
    while(in.hasNextLine()) {
         String s = in.nextLine();
         System.out.println(s);
    }BufferedReader:
    Process proc = Runtime.getRuntime().exec("...");
    BufferedOutputStream out = new BufferedOutputStream(proc.getOutputStream());
    BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    String l = " ";
    while(l != null) {
         l = r.nextLine();
         System.out.println(s);
    }

  • Java command line programming in windows

    Here's what I want to do:
    -write .java files in a text editor
    -compile and run them from a command line, rather than using a
    compiler like codewarrior or MS J++
    Here's my problem:
    In a program that produces output, I can't seem to find a way to
    retain the output that goes off the screen in a DOS window. Is there
    a way to enable scrolling in a DOS window, or are there any
    alternative command line terminals for Windows? Any suggestions
    would be greatly appreciated.

    I think you can increase the Screen Buffer size which should give you a scroll bar. For this right click on the icon on the top left of the DOS window -select Properties - Go to Layout tab.
    Another option will be to redirect the output to a file
    java SomeClass > log.txt
    Hope this helps.

  • How do I pause C command-line program?

    Hello. I'm writing a little command-line game app in C and I'm curious about how I can pause the program to wait for the user to hit return. I want the user to need to hit return (or having to hit any key would work too) to make the program continue, and I would like the key that was hit not to appear on the screen -- just a simple sort of "hit any key to continue" type thing. In C++ I think we used something like system("Pause") or something like that -- don't really remember, but any help here will be greatly appreciated. Thanks!

    Something like this will print a prompt, then wait for a keystroke:
    printf("Hit any key to continue> ");
    getchar();
    However in a console application, it's not so easy to prevent the user's keystrokes from being echoed. There are ways to turn the echo off for the keystroke then restore it, but those can depend on the environment. I'd need to know whether you're running your program in an Xcode console window, a Terminal window, or elsewhere. In short, don't go there unless it's quite important to you. The above prompt will show any chars that are keyed-in as text after the arrow, which is what a user would expect.
    Hope that helps!
    - Ray

  • Problem executing command line program

    Hi I have a tuxedo command line app in Solaris 2.6. I was able to execute the program from unix prompt however when I try to do it from JAVA program, it does not work.
    I have to execute from command line as follows
    $ud32<SPACE>-U<SPACE>login<nl>
    SRVCNM<TAB>CB_EXESUB<nl>
    CLFY_SUB<TAB>ExeternalMsg<nl>
    EQUIP_ID<TAB>1<nl>
    <nl>
    during command line execution from second line on you will not get the prompt. After entering a balnk line the program will execute and provide the output.
    I was aslo able to execute the program by putting the last 4 lines in a file(say test.bat) and executing by issuing following command at the unix prompt
    $ud32 -U sa<test.bat
    My java program as follows.
    import java.io.*;
    public class udexec {
    public static void main(String args[]) {
    try{
    Runtime rt = Runtime.getRuntime();
    System.out.println("Before");
    Process prcs = rt.exec("ud32 -U sa");
    System.out.println("After: " + prcs);
    InputStreamReader isr = new InputStreamReader(prcs.getInputStream());
    PrintWriter out = new PrintWriter(prcs.getOutputStream());
    out.println("SRVCNM CB_EXESUB");
    out.println("CLFY_SUB ExternalMsg");
    out.println("EQUIPID 1");
    out.println("");
    int ret = isr.read();
    String line;
    System.out.println("Before Print");
    System.out.println(ret);
    catch (Exception e) { System.out.println(e); }
    Any help will be greatly appreciated.
    Thank You
    Raju

    Hmm, maybe you should also give additional Excape Characters to the Process (so adding \t where you have written <TAB>, or adding \r to the lines).

  • Is there any command line i can use to install a .pkg file to my own directory?)

    I'm a newer of Mac OS X, i need to insatll lots of .pkg package to my mac machine, so i think of install them use a script automatically, but i cnanot find any way to use the command line to insatll the .pkg package to my own forder(like /myapp). can somebody help me? thanks a lot.

    Here's a article on how to move your home dir:
    How to Move the Home Folder in OS X – and Why
    The key basic steps are to copy your home dir to another drive and using the Accounts Preferences advanced options for the your account to redefine where your home dir is.
    With or without the home dir moved you can organize your apps as you see fit.  I keep my apps categorized; doc/text related apps, video apps, calculators, etc.  They could even be on a third drive if you want, but that makes backups a bit more complicated (always backup).
    The advantage of keeping the home dir separate from the boot dir is (a) if the boot drive fails it doesn't take your stuff with it, (b) it allows you to have multiple boot drives and switch among them if necessary while using the same home dir, and (c) if you use a ssd for a boot drive it allows you to use a relatively small ssd (I use a 120GB).
    With a ssd as a boot drive you could still elect to put key apps on it for performance reasons.  I do that for commonly used stuff.  But it's mainly reserved for the boot system.  I try not to put any more that I have to on it just to minimize needless writing to the ssd.  Of course you cannot stop ssd writes by the OS itself (e.g., swap space -- but that too can be minimized with enough ram).

  • Command line program install

    I need to install a program on several Macs that I manage. All Macs, save 1, are OSX 10.9
    I do not want to go visit each mac personally not to mention interrupt the user to install a quick support program. Does anyone know if it's possible to ssh and do a command line install for GoToAssist Unattended Client? This may be a G2A question rather than an OSX question, but I was wondering if anyone had any experience or advise for command line installing a program via SSH? This will allow me to do all the installs behind the scenes from my mac and not bother the users.
    Thank you all in advance!

    I was able to figure it out on my own and thought I would share in case anyone else needed the help later.
    $ sftp localuserAccount@IPaddress_or_DNSNAME
    password:(this will be your local user password)
    sftp> put /Users/myusername/Desktop/NewSoftware.pkg
    sftp>exit
    $ssh localuserAccount@IPaddress_or_DNSNAME
    password:
    $ sudo installer –store –pkg /Users/localuserAccount/NewSoftware.pkg
    password:
    Once the installation completes
    $exit
    In my case the remote computer that I installed the new software on needed to be rebooted but I will not always necessary.
    Cheers!

Maybe you are looking for

  • Payroll control - RA issue

    1. In payroll, Which retro active date takes precedence ? Assume an employee is having payroll area A1 a. Payroll control record -> Earliest retro acctg period for Payroll area A1 - 01.12.2011 b. Emp X, who belongs to Payroll area A1 -> Earl.pers.RA

  • STO without delivery-CIN

    Hi All,      I got the solution from the forum but I am struck up in J1IS with some doubts working with J1IS. I have 2 plants 1000 and 2000 under one company code. Sometimes due to shortage we transfer goods like spare parts, raw materials, etc from

  • Error "ASSIGN_SUBSTRING_NOT_ALLOWED" doing archiving

    Hi  everybody I have an ECC 6.0 SAP System and I m trying to implement an archiving process for the MM_MATBEL object. I am using the SARA transacction --> Basis Customizing --> Cross-Client File Names/Paths I defined a logical file path definition "A

  • IPod Classic won't charge using MA242LL/A

    I recently purchased a used MA242LL/A AV connection kit for use with my 120GB iPod classic. The MA242LL/A connection kit contains a connector cable with a firewire output, which plugs into the 2-prong power adapter, however, my iPod will not charge w

  • Power factor, reactive, active and apparent power

    Good morning, I have a VI that make some math calc and give me the power factor from the system, but when I'm trying to show it in a waveform graph I have some problems. First I have to fix the scale: -1 to 1  Second that you all know if the values g