Directing std output to the console window

I am trying to direct the standard output from a separately executed console program to the console window belonging to the running application. How can I do this?
For example, in the following code, if I execute the simple Windows 'dir' command using .exec, how can I make the output go to the application's console instead of going to a separate window?
import java.io.*;
class dir
  public static void main(String[] args)
    try
      Process runprogram = Runtime.getRuntime().exec("cmd.exe /C start dir");             
    catch(IOException e){}
}

First I will post the mandatory link for everybody who asks about Runtime.exec():
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Read that and notice the bit about getting data from the process's output stream. You can copy that data to the console.

Similar Messages

  • Can you change the color of the output in the console?

    When you run your program using NetBeans the color of the output in the console window is black. Is there any way to change the color of the output to say blue?

    Hi AJL,
    There is no way to color rows of the table control in a SUDialog. You could consider using the ActiveX container control and using the Microsoft ActiveX table control, which might have that functionality. Note though, that then you need to either ensure that control is always on all your client machines or make provisions for it to be installed/registered.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Input a string and assign to a variable in the console window

    i'm absolutely and completely new to java
    i need to be able to input a string and then assign it to a variable, entirely using the console window, basically i'm looking for the Java alternative to C++'s "cin"
    i've tried the System.in. method but nothing seems to work
    i know this should be simple, but i cant find it anywhere
    cheers

    i've tried the System.in. method That thing is not a method: it's an object, an intstantiation of the InputStream
    class. If you read the API documentation for that class you'll notice that it
    isn't much more sophisticated than C's file IO. You can wrap an
    object if this class in a more high level class (see InputStreamReader
    and BufferedReader).
    The latter allows you to read an entire line of characters. If you really want
    to go fancy you can wrap the first class in a Scanner which is only
    available in Java 1.5
    kind regards,
    Jos

  • How can I disable the console window shown by JWS on the client machine

    Hi,
         When I open the JWS Application Manager, and go to File ->Preferences -> Advanced tab and select Show Java Console, it opens up a small window displaying all the error messages. I want that when a client downloads my JNLP application and selects this option he is not able to see the console window. How can I achieve this?
    Thanks,

    You can check on the <b>about:config</b> page if the browser.urlbar.autocomplete.enabled pref is set to false if you want to disable the location bar drop down list.
    *http://kb.mozillazine.org/about:config

  • How can get the console window name of the current form?

    How can get the console window name of the current form?

    Try the various get methods of the viewObject such as getQuery:
    http://www.oracle.com/webapps/online-help/jdeveloper/10.1.2/state/content/navId.4/navSetId._/vtAnchor.getQuery%28%29/vtTopicFile.bc4jjavadoc%7Crt%7Coracle%7Cjbo%7CViewObject%7Ehtml/

  • My first PKGBUILD - stock ticker style output on the console

    I created my first PKGBUILD of a simple program I wrote called "ticker" which just converts input text to scrolling stock ticker style output on the console.
    The PKGBUILD and a screenshot are at http://www.fial.com/~scott/ticker 
    I'd like to submit it to the AUR, but I'd really appreciate any comments/advice first.
    Scott
    Last edited by scottfial (2010-07-04 00:38:38)

    Writing what it's about in your post (title) would help building interest, I suppose.

  • RRI output in the same window

    BW Consultants:
    I have a WAD in nw 2004s. I am jumping from Q1 to Q2. The users want to see the output of Q2 in the same window as the inital results for Q1. I checked help.sap.com and they mentioned this functionality in WAD RRI_OPEN_MODE. Sure, I checked the WAD - properties and cannot display Q1 and Q2 output in the same window.
    Any idea?
    Regards
    RAP

    Hello,
    have you applied the last RRI patch?
    Check OSS Note 1296575 - "RRI: REPLACE_WEB_APPLICATION opens new window".
    Best regards
    Edited by: M Lange on Jul 1, 2009 7:50 PM
    Edited by: M Lange on Jul 1, 2009 7:50 PM

  • Capturing all the text that I output to the console

    HOw do I capture all the text I output to the console to a file. I know how to open filebuffers and all that, well I don't really know, but I have some sample code that I can follow. I am just wondering if I am suppose to just open the file buffer, then run my normal application with all the system.out.println() statements and then have that fed to a file? Right now I am using a lot of println() statements to debug, and I would like to be able to push it into a file so I can look at it later, without having that console line limitation.
    My guess is to just open up a filestream and have it open and then run my normal code and then close the filestream at the end. Can somebody let me know if that is good enough...
    let say I have a static method hat outputs a bunch of text, can I do this
    filestream open
    static method run
    filestream close
    and that's it.

    I could see why you'd want to automatically
    route output to a file, that normally would
    go to the console. There might be use for
    capturing output lines.
    If the question is to avoid having to specify
    the output on the command line, then what
    one can do is to create a ".bat" file.
    Ex.
    kstring.bat
    ======================================
    @java kstring > kstring.out
    Now in executing, you'd just ==> kstring
    Which will execute the kstring.bat,
    and since "> kstring.out " is inside
    the "bat", your output goes to the
    kstring.out, instead of the console.
    This would be another way, saves all the
    redirection in Java code. Just use the
    DOS command inside a xxx.bat file.
    Just my opinion, may not work in your
    circumstance.
    -- gte99te

  • Output to the console

    Hi,
    How can we output easily a message to the console when running a function?

    You will also have to do a
    set serveroutput on;
    on the console to get the messages.
    Rajat,
    OTN Team @IDC

  • How do I remove an unwanted server from the console window?

    Hi all, hope someone can help, as I'm rapidly running out of hair to pull out :-(
    I have one upstream server, set up perfectly on Windows Server 2012, and six downstream servers all running Windows Server 2008 R2 Enterprise. Five of my downstreams are set up and working as expected, but one is behaving a little strangely.
    Here is an example of one of my downstream servers which is configured correctly:
    Just showing the upstream server, as you would expect.
    Now here's my problem downstream server:
    As you can see, not only does it list the upstream server, as expected, it also shows itself as a server. I have tried right-clicking it and choosing 'Remove from Console', but it just comes back after closing and reopening the console.
    Any advice would be greatly appreciated,
    Carl...

    On all downstream servers, except ServerDOWN4 only the ServerUP01 is seen in the WSUS console. On ServerDOWN4, you can see ServerUP01 and ServerDOWN04 in the WSUS console.
    Is this normal?
    No, and the short answer here is that apparently the consoles were configured to connect to the wrong server, and on 'DOWN4', TWO servers were configured in the console.
    But here's a more significant question....
    Why, on WS2012 and WS2008R2 servers are you using the standalone console anyway? If you use
    SERVER MANAGER, which is the expected behavior, the *LOCAL* server will be automatically displayed.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • Clearing the console window

    hi,
    I'm currently writing a relatively simple CLI based java program, such that I'm just (for output) using System.out.* type functions...
    anyway, it'd make my application look a fair bit better if I could clear the console where I output the text...
    is this possible (under unix or windoze)? if so, any hints?
    regards,
    Jack

    I haven't tried this myself, but you might try looking at a program called jcurzez.

  • How to get the select * from emp table output on the console  using java

    public class software {
          * @param args
         static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
         static final String DATABASE_URL = "jdbc:oracle:abc";
         private static Connection connection;
         private static Statement statement;
         public static void main(String[] args) {
              // TODO Auto-generated method stub
         try {
              System.out.println("-------THIS IS THE Class.forNameJDBC_DRIVER");
                   Class.forName(JDBC_DRIVER);
                   System.out.println("THIS IS THE Class.forNameJDBC_DRIVER");
                   connection = DriverManager.getConnection(DATABASE_URL, "abc",
                   "abc");
                   System.out.println("THIS IS THE connection abc ,abc");
                   statement = connection.createStatement();
                   //Query to find the values in the EMP table.
                   ResultSet resultSet = statement.executeQuery("SELECT * from EMP");
                   if(resultSet.next()){
                   System.out.println("THESE ARE THE VALUES IN EMP TABLE:"+resultSet);  /// How can i get all the values record wise on the  console ??????
                   resultSet.close();
         catch (ClassNotFoundException classNotFound) {
                   System.out.println("Driver not Found"+classNotFound.getMessage());
              } catch (SQLException sqlException) {
                   System.out.println("SQL Exception - bad sql");
                   System.out.println(sqlException.getMessage());
    }

    1sai
    Please assign the dukes here and in your previous threads.
    See [http://wikis.sun.com/display/SunForums/Duke+Stars+Program+-+How+it+Works]
    You are currently the all time career leader in un-awarded dukes, with including this thread 75 unawarded dukes for questions you marked as answered.
    It's even worse when you look and see that you have awarded many dukes as well. So you do know how to do it. You're just too lazy and rude to be bothered.
    Don't be a lazy wank.

  • Open reference / output in the same window

    I want a vi (opened and started at runtime per reference) to display
    its data on the frontpanel of the calling VI. How can this be done?
    Thanks,
    Andre

    THis can be done using control references.
    Pop-up on the control you want the sub-VI to update. Create a reference to the control. Pass this reference to the called sub-VI when it is called (via its connector pane).
    Inside the sub-VI, use a property node>>>value to update the indicator when required.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to get rid of the console window and keep the GUI?

    i made a jar, but my app needs the API to sniff the network.
    i made a .bat file so that i can run the jar file without having to type in the commands.
    //contents of myApp.bat
    start java -Djava.library.path="jnetpcap-1.3.0" -jar myApp.jarthe problem is, there's this fugly CMD prompt that just wont go away. if i close it, it closes my app as well. so, how do i solve this?
    thanks.

    Use the "javaw" command instead of the "java" command.

  • JNI: Reading Java output from console window

    Hi!
    Sorry if this is wrong place to put this topic, but I didn't know where to put it, so now it's here.
    I'm trying to make a launcher program with C++ which would start my java program. I'm using "env->CallStaticVoidMethod (romexisClass, mid, args);" and it works perfectly. But I'd like to read the text which my java program outputs to the console window and save it into a text file. Is this possible and how? It looks like I stdout etc. won't work.
    Or as other option I could use some Java Exe Wrapper, but I haven't found any which would allow passing arguments to the main() without -D option and I need to be able to read those arguments from a .ini-file. It should be a subtitute for the following command "java -Xss$var1k -Xms$var2m -classpath $var3 test.program host=$var4" in which I'd read $vars from a .ini-file.
    Thx,
    Lassi

    Maybe this will do the job:
    http://cboard.cprogramming.com/archive/index.php/t-86580.html

Maybe you are looking for

  • Recording Real Instruments via Garage Band

    Hi, im hoping that this is a quick fix, some small detail ive overlooked. im recording with garageband, and have had constant issues which i have overcome at each step in the process. Right now im using a KORG M50 keyboard, and a microKORG, to create

  • Can HP/otherPEOPLE RESPOND to MISSING "ATA PASSWORD" FEATURE IN BIOS (SECURITY) ??

    Hello people, Can you please answer following ?: Note: I can fix anything (Engineer & x-Tech here), so rarely (if ever) ask for help, but one problem is killing me with certain consumer (nonbusiness) laptop: I purchased HP: ProductName#: "DM1Z" (DM1Z

  • Boot Camp update 3.1

    I installed Win7 on Boot Camp 3.0.1, soon after getting the Macbook Pro. I then installed Parallels 5, and set it to use the Win7 installation. Soon afterward I got invalid activation number notices, and had to get a phone re-act from Windows, which

  • Apple TV not seing my DirecTV Genie RC71 Remote

    Just received a Genie RC71 today with an RC71 remote from DirecTV.  Everything is working great, except I can't seem to program my Apple Remote to the RC71.  I am supposed to be able to "add a remote" to my apple TV, and press the "up" button on the

  • Reg: Mass generation of roles with open authorization

    Hi,          Is there an option to mass generate roles with open authorizations ?          It would be helpful if it there exists some transactions or reports that would help in doing so unlike CATT scripts or batch sessions. Regards,