Get output from dos window to jtextarea/textarea

hi
i am executing the following lines of code:
1)Runtime r=Runtime.getRuntime();
Process p=r.exec("javac <filename.java>");
when executing this there is no exception fired but i am not being able
to get the output from the ods console to a textarea
or for that matter i donot get any output anywhere
2)if i change it to
Process p=r.exec("java <filename");
similar thing happens i.e no output
can anyone plz help
thanx.

Sorry, this < was the wong way around
Process p=r.exec("java filename >test.txt")
Then read in data from test.txt, something like this should do it :))   public String getTextFile(String text) throws Exception{
      int reader = 0;
      text = "";
      FileReader in = new FileReader("test.txt");
         do {
            reader = in.read();
            text += (char)reader;
         }  while (reader != -1);
      in.close();
      return text;

Similar Messages

  • Get output from dos window to jtextarea

    the code is:
    Runtime r=Runtime.getRuntime();
    Process p=r.exec("javac <filename>");
    i have used
    BufferedReder br=new BufferedReader(new InputStreamReader(p.getOutputStream));
    but on compilation it shows error
    plz someone help
    i need it urgently.

    Sorry, this < was the wong way around
    Process p=r.exec("java filename >test.txt")
    Then read in data from test.txt, something like this should do it :))   public String getTextFile(String text) throws Exception{
          int reader = 0;
          text = "";
          FileReader in = new FileReader("test.txt");
             do {
                reader = in.read();
                text += (char)reader;
             }  while (reader != -1);
          in.close();
          return text;

  • My HP wireless printer keeps getting deleted from my windows 7 PC. Why?

    I have a HP Photosmart D110A e-printer and every once and awhile it get deleted from my Windows 7 PC and I have to add it again, What is going on with this. Any tips would be great.

    It should.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • I dont have data in "Client status summary" report for servers in server collection, but get data from our Windows 7?

    Hi,
    I dont have data in "Client status summary" report for servers in server collection, but get data from our Windows 7?
    So and idea of way I dont get data from or servers? Missing client setting for servers?
    /SaiTech

    Hi,
    I do see the server in Server collections in "Monitoring--Client Status--Client Activity" but not in reports like "Clients with failed client check details" i get "No Data Available"?
    /SaiTech

  • Getting output from a process

    hi friends and gurus!
    can somebody give me actuall working code to get the
    output from a process let's say Process p=Runtime.exec("cmd c/ dir c:"); in windows,
    and stores the output in a textfile let's say out.txt.
    please give me the java code and not hints!
    any effort to help me will be highly appreciated.
    Thanx in advance!
    sparya.

    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    class read{
    public static void main(String[] args){
    String data=""
      try{
       BufferedReader reader=new BufferedReader(new FileReader(new File(args[0])));
       while((data=reader.readLine())!=null){
        System.out.println(data);
      catch(FileNotFoundException fnfe){
       System.out.println("cant find file "+args[0]);
      catch(IOException ioe){
       System.out.println("cant read file "+args[0]);
    }to use type java read filename (including path if you need it)
    hint, type java read read.java (cool, its nearly a palindrome)

  • Writing console output from numerous classes to JTextArea?

    I have written a GUI for several classs and I was wondering if it is possible to have the output from these classes written to something like a JTextArea or equivalent.
    I know I could store the output (instead of System.out.print) and then setup a JTextArea and set the text equal to the stored output. I was hoping there was another way to do this that'd be more aesthetic.
    Thanks in advance.
    Se�n

    I have written a GUI for several classs and I was
    wondering if it is possible to have the output from
    these classes written to something like a JTextArea
    or equivalent.
    I know I could store the output (instead of
    System.out.print) and then setup a JTextArea and set
    the text equal to the stored output. I was hoping
    there was another way to do this that'd be more
    aesthetic.
    java.util.logging?Alternatively, create a TextAreaPrintStream class, overriding the appropriate methods and then call
    System.setOut(someTextAreaPrintStream);Jim S.

  • Error Getting Output From ICloudTask

    I went through the Azure Batch Tutorial for .NET and am having issues with getting the output from the ICloudTask. After waiting for the tasks to complete I have the coded below:
    foreach (ICloudTask task in listjob.ListTasks())
    string taskFileContent = task.GetTaskFile(Constants.StandardOutFileName).ReadAsString();
    Console.WriteLine("Task " + task.Name + " says:\n" + taskFileContent);
    It throws a System.AggregateException on task.GetTaskFile with an inner exception of:
    {"The remote server returned an error: (404) Not Found."}
    I did some research but haven't been able to determine why I am getting this error?

    I see in the sample that the second use of TaskStateMonitor (TSM) does not check for timeout...  We will add this and you might want too as well.  
    If the TSM times out you might want to confirm the pool has VMs and that they reach TVMState.Idle (i.e.: are available to run tasks).
    You do not mention the exact task state you see but it is possible for a task to be in the TaskState.Completed state and still not have a stdout.txt file.
    You could list the files with ICloudTask.ListTaskFiles(recursive: true) to see what files are actually there.
    Also you can check the exit code (ICloudTask.TaskExecutionInformation.ExitCode) and/or the the TaskSchedulingError (ICloudTask.TaskExecutionInformation.SchedulingErrro) to see if the task ran correctly.
    daryl
    ps: don't forget to ToString() the inner BatchException.  I posted to the forum earlier on this and there are data in the exception that can tell you more than "not found"... 

  • Configuring DNS when clients get DHCP from a Windows server

    Hi
    I'm getting to grips with OD and have managed to configure a test environment at home with static IPs and all the DNS entries being entered manually for each computer.
    However, how do I configure the DNS in an environment where clients get their IPs from a Windows DHCP server (which I have no access to)?
    Setting clients to have static IPs is not an option nor enabling DHCP on the Mac server, I suspect.
    Your help is really appreciated.
    Steve

    Hi
    Your suspicion is correct.
    To be honest I would what is available on the Windows Server as the basis for your Open Directory deployment. If the Windows Server is already the DHCP Server odds are it is also the DNS Server. DNS can be provided to your clients using the Windows based DHCP service.
    If you have no direct access to the windows server you should be able at the least ask the windows administrator to add a Host Record with a Reverse Pointer for the OSX Server. Make sure its resolving correctly first using the relevant tools first then add the IP address of the Windows Server in the network preferences pane on your OSX Server. Thereafter you should be able to promote from Standalone to Open Directory Master without too many problems.
    If the Windows Server is using .local as its FQDN then it could scupper any chances you have of providing OSX LDAP services to your mac clients. It can work with .local, its just better if its not used.
    Hope this helps – Tony

  • Getting rid of Dos Window during "java" call

    Hi All
    I am trying to execute a batch file in windows which internally calls a "java" class file. while executing the class file the batch file launches a dos window in the backgroud..can anyone please tell me how to get rid of that dos window
    Thanks in Advance.
    Regards
    Kiran.R

    Instead of using java command in your batch file, change it to use javaw instead.
    V.V.

  • Not getting outputs from JavaScript Patch in QC2

    The JavaScript Patch no longer generates outputs from outputs[n]. The outputting of data just stopped.
    An example output generator (no other instructions in the JavaScript patch):
    outputs[0] = "string";
    was sent to an Image With String patch and then to a Billboard patch (the only existing patches). No text appeared in the viewer. When in Editor, the cursor placed over Output #0 shows only:
    Type Virtual
    with no value. The input string into Image With String shows "".
    When disconnecting the JavaScript patch from the Image With String patch and I entered "help", the text help appeared in the viewer.
    I reinstalled Quartz Composer and there was no change. Anyone have any idea what is going on?

    What I've learned: the Tascam 122L has known issues when working with Leopard. Back in the store, I plugged another external card (Presonus Audiobox USB), which immediately worked with the Mac as though they were friends since birth.
    I am rapidly warming to Mainstage.

  • How to get data from serial port to GUI textArea

    From Serial Port.....
    Messages from base (always 5 bytes):
    0xAA, 0, 0, 0, 0xBB - IDLE Mode
    0xAA, 0, 0x80, 0x80, 0xBB - Question Mode
    messages from terminal (always 6 bytes):
    0xAA, a, b, c, chksum, 0xBB
    where chksum = a+b+c;
    a = address (0-250)
    the 2 MSB's of b represenet the answer:
    0 0 - A
    0 1 - B
    1 0 - C
    1 1 - D
    the 6LSB's of b and 8bits of c is the time for answer, in milliseconds.
    (0-16384 milliseconds)
    I have VB Code for that but I want the same thing in Java ...
    Can any one help me?
    Here's VB Code..
    VERSION 5.00
    Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
    Begin VB.Form Form1
       BorderStyle     =   1  'Fixed Single
       Caption         =   "Aakar GUI"
       ClientHeight    =   4665
       ClientLeft      =   60
       ClientTop       =   375
       ClientWidth     =   6105
       LinkTopic       =   "Form1"
       MaxButton       =   0   'False
       MinButton       =   0   'False
       ScaleHeight     =   311
       ScaleMode       =   3  'Pixel
       ScaleWidth      =   407
       StartUpPosition =   3  'Windows Default
       Begin VB.CommandButton cmdPort
          Caption         =   "Open Port"
          Height          =   375
          Left            =   120
          TabIndex        =   4
          Top             =   600
          Width           =   1455
       End
       Begin VB.ComboBox cmbPort
          Height          =   315
          ItemData        =   "Form1.frx":0000
          Left            =   120
          List            =   "Form1.frx":0016
          Style           =   2  'Dropdown List
          TabIndex        =   3
          Top             =   120
          Width           =   2895
       End
       Begin VB.CommandButton cmdEnd
          Caption         =   "End"
          Height          =   495
          Left            =   1560
          TabIndex        =   2
          Top             =   1320
          Width           =   1215
       End
       Begin VB.CommandButton cmdStart
          Caption         =   "Start"
          Height          =   495
          Left            =   120
          TabIndex        =   1
          Top             =   1320
          Width           =   1215
       End
       Begin VB.TextBox txtMessage
          Height          =   2040
          Left            =   119
          MultiLine       =   -1  'True
          ScrollBars      =   3  'Both
          TabIndex        =   0
          Top             =   2475
          Width           =   5848
       End
       Begin VB.Timer tmrRead
          Enabled         =   0   'False
          Interval        =   1
          Left            =   2040
          Top             =   600
       End
       Begin MSCommLib.MSComm MSComm1
          Left            =   3120
          Top             =   360
          _ExtentX        =   1164
          _ExtentY        =   1164
          _Version        =   393216
          DTREnable       =   0   'False
          ParityReplace   =   45
          SThreshold      =   1
       End
       Begin VB.Label Label5
          Caption         =   "Result Data:"
          Height          =   375
          Left            =   120
          TabIndex        =   5
          Top             =   2115
          Width           =   1320
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    Dim PortIsOpen As Boolean
    Dim Answers(4) As String
    Dim RejectKeystroke As Boolean
    Private Sub cmbPort_Change()
    Debug.Print cmbPort.ListIndex
    End Sub
    Private Sub cmbPort_Validate(Cancel As Boolean)
    'Cancel = True
    End Sub
    Private Sub cmdEnd_Click()
    MSComm1.Output = "e"
    txtMessage.Text = ""
    End Sub
    Private Sub cmdPort_Click()
    On Error GoTo ErrorHandler
    If cmbPort.ListIndex < 0 Then Exit Sub
    If PortIsOpen Then
        cmbPort.Enabled = True
        MSComm1.PortOpen = False
        PortIsOpen = False
        cmdPort.Caption = "Open Port"
        cmdStart.Enabled = False
        cmdEnd.Enabled = False
    Else
        MSComm1.CommPort = cmbPort.ListIndex + 1
        cmbPort.Enabled = False
        MSComm1.PortOpen = True
        PortIsOpen = True
        cmdPort.Caption = "Close Port"
        cmdStart.Enabled = True
        cmdEnd.Enabled = True
    End If
    Exit Sub
    ErrorHandler:
    Debug.Print Err.Number
    Debug.Print Err.Description
    MsgBox Err.Description, vbExclamation Or vbOKOnly, "Error opening port"
    cmbPort.Enabled = True
    PortIsOpen = False
    cmdPort.Caption = "Open Port"
    cmdStart.Enabled = False
    cmdEnd.Enabled = False
    End Sub
    Private Sub cmdStart_Click()
    MSComm1.Output = "s"
    txtMessage.Text = ""
    End Sub
    Private Sub Form_Initialize()
    Dim tmp As Variant
    tmp = InitCommonControls
    End Sub
    Private Sub Form_Load()
    Answers(0) = "A"
    Answers(1) = "B"
    Answers(2) = "C"
    Answers(3) = "D"
    'MSComm1.Settings = "9600,n,8,1"
    ''MSComm1.Settings = "115200,n,8,1"
    'MSComm1.PortOpen = True
    On Error GoTo ErrorHandler1
    MSComm1.CommPort = 1                    ' comm port 1
    MSComm1.RThreshold = 1                  ' use 'on comm' event processing
    MSComm1.Settings = "9600,n,8,1"         ' baud, parity, data bits, stop bits
    MSComm1.SThreshold = 1                  ' allows us to track Tx LED
    MSComm1.InputMode = comInputModeText    'comInputModeBinary  ' binary mode, you can also use
                                            ' comInputModeText for text only use
    PortIsOpen = False
    cmbPort.ListIndex = 0
    ' open the port
    MSComm1.PortOpen = True
    cmbPort.Enabled = False
    PortIsOpen = True
    cmdPort.Caption = "Close Port"
    cmdStart.Enabled = True
    cmdEnd.Enabled = True
    Exit Sub
    ErrorHandler1:
    Debug.Print Err.Description
    PortIsOpen = False
    cmbPort.Enabled = True
    cmdPort.Caption = "Open Port"
    cmdStart.Enabled = False
    cmdEnd.Enabled = False
    End Sub
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If MSComm1.PortOpen Then MSComm1.PortOpen = False
    End Sub
    Private Sub lblOption_Click()
    End Sub
    Private Sub MSComm1_OnComm()
    ' Synopsis:     Handle incoming characters, 'On Comm' Event
    ' Description:  By setting MSComm1.RThreshold = 1, this event will fire for
    '               each character that arrives in the comm controls input buffer.
    '               Set MSComm1.RThreshold = 0 if you want to poll the control
    '               yourself, either via a TImer or within program execution loop.
    '               In most cases, OnComm Event processing shown here is the prefered
    '               method of processing incoming characters.
        Dim i As Long
        Dim sBuff    As String           ' buffer for holding incoming characters
        Const MTC       As String = vbCrLf  ' message terminator characters (ususally vbCrLf)
        Const LenMTC    As Long = 2         ' number of terminator characters, must match MTC
        Dim iPtr        As Long             ' pointer to terminatior character
        ' OnComm fires for multiple Events
        ' so get the Event ID & process
        Select Case MSComm1.CommEvent
            ' Received RThreshold # of chars, in our case 1.
            Case comEvReceive
                ' read all of the characters from the input buffer
                ' StrConv() is required when using MSComm in binary mode,
                ' if you set MSComm1.InputMode = comInputModeText, it's not required
                'sBuff = sBuff & StrConv(MSComm1.Input, vbUnicode)
                'If Len(txtMessage.Text) > 4096 Then txtMessage.Text = ""
                sBuff = MSComm1.Input
                Dim ch As String
                Dim PacketStart As Boolean
                Dim PacketLength As Integer
                Dim Packet() As String
                PacketStart = False
                PacketLength = 0
                While (Len(sBuff) > 0)
                    ch = Left(sBuff, 1)
                    If (ch = Chr(&HAA)) Then PacketStart = True
                    If (ch = Chr(&HBB)) Then PacketStart = False
                    If (ch <> Chr(&HAA) And ch <> Chr(&HBB)) Then
                        PacketLength = PacketLength + 1
                        ReDim Preserve Packet(PacketLength)
                        Packet(PacketLength) = ch
                    End If
                    'txtMessage.Text = txtMessage.Text + Format(Hex(Asc(ch)), " @@")
                    sBuff = Right(sBuff, Len(sBuff) - 1)
                Wend
                If (PacketLength = 3) Then
                    Debug.Print "Command packet recieved"
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(1)))
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(2)))
                End If
                If (PacketLength = 4) Then
                    Debug.Print "Response packet recieved"
                    txtMessage.Text = txtMessage.Text + "Address =" + Str(Asc(Packet(1))) + _
                        " Answer = " + Answers((Asc(Packet(2)) And &HC0) / 64) + _
                        " Time =" + Str((Asc(Packet(2)) And &H3F) * 256 + (Asc(Packet(3)))) + "mS" + vbCrLf
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(1)))
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Option =" + Str((Asc(Packet(2)) And &HC0) / 64)
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Time =" + Str((Asc(Packet(2)) And &H3F) * 256 + (Asc(Packet(3))))
                End If
                If (PacketLength <> 4 And PacketLength <> 3) Then Debug.Print "Unknown packet of length" + Str(PacketLength) + " recieved"
                txtMessage.Text = txtMessage.Text + vbCrLf
            ' An EOF charater was found in the input stream
            Case comEvEOF
                DoEvents
            ' There are SThreshold number of characters in the transmit  buffer.
            Case comEvSend
                DoEvents
            ' A Break was received.
            Case comEventBreak
                DoEvents
            ' Framing Error
            Case comEventFrame
                DoEvents
            ' Data Lost.
            Case comEventOverrun
                DoEvents
            ' Receive buffer overflow.
            Case comEventRxOver
                DoEvents
            ' Parity Error.
            Case comEventRxParity
                DoEvents
            ' Transmit buffer full.
            Case comEventTxFull
            ' Unexpected error retrieving DCB]
            Case comEventDCB
                DoEvents
        End Select
    End Sub
    Private Sub tmrRead_Timer()
    'MSComm1.Output = vbCrLf + vbCrLf
    'MSComm1.Output = Chr(128)
    End Sub
    Private Sub txtMessage_KeyDown(KeyCode As Integer, Shift As Integer)
    If Shift = 2 Or Shift = 4 Then RejectKeystroke = False Else RejectKeystroke = True
    End Sub
    Private Sub txtMessage_KeyPress(KeyAscii As Integer)
    If RejectKeystroke Then
        KeyAscii = 0
    End If
    End SubThanks in advance..

    I want to replicate the entire VB program as Java Program.
    This has to be included in my project which i am doing in java.

  • Getting output from an OS command from an ABAP program

    Hi Folks!
    I have a requirement, is it possible to call an operating system command, and also get its output back to the ABAP program that has called it?
    For example, from an ABAP program calling the "dir" command from Windows and getting back (as a string) the directory listing to the ABAP program?
    Thanx in advance!
    Juan.

    This is will help you
    << Moderator message - links removed >>
    Please do not post a list of links. This simply encourages laziness. The OP could have found these with a little work.
    Edited by: Rob Burbank on Dec 13, 2010 9:19 AM

  • Getting output from a C programme

    Hi
    I am trying to execute a C programme (.o file) on Solaris and get its output .
    The C programme is a simple function which returns 0 or more then zero after executing some logic .
    I tried to use Runtime.exec() method but was not able to get any out put from the function , where as I did same in a perl script and was able to get the output .
    I have even tried to get error stream , input stream but I always get -1 as a return value .
    Following is my program
    Runtime rt = Runtime.getRuntime();
    String[] arg =new String[]{"program","arg1","arg2"};
    Process p =rt.exec(arg);
    BufferedInputStream buf = new     BufferedInputStream(p.getErrorStream());
    int data=buf.read();
    System.out.println("date is "+data);
    BufferedInputStream buf1 = new     BufferedInputStream(p.getInputStream());
         while((data=buf1.read())!= -1)
              System.out.println("data input is "+data);
    arg1 and arg2 are 2 arguments that the program needs . It always returns a value with might be 0 or non zero.
    I know I can try to use JNI , but i beleive using Process is a simple solution (if it works)
    Thanks

    .o files are usually no executables but object files. They need to be linked (with an object including the main funtion) to yield an executable.
    Shared objects are usually called *.so.

  • 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

  • Downloaded Microsoft Office 365.  Wanted to use files originally done on Windows Word to my Ipad word app.  How do I get documents from a Windows source--even through someting like dropbox--into my i pad so I can work on them?

    How can I use document such as word or excell docs from my home windows based computer  in my office 364 ipad word or excell app that I downloaded for my ipad...   any suggestions out there?.

    I presume you have already downloaded the free M.S. office apps to use with your 365 subscription?   (Even if you haven't there are several other apps that will read these as well - )
    You can get the documents onto your pad several different ways.
    1. easiest for a single document is to simply e mail to your self.  In mail, tap the attachement once to cause it to down load.  then touch and hold the attachment until the 'open in ' box pops up, and choose the app you want to se.  The document will be saved with that app.
    for a loy of docs, it is easier to use the sharing system in I tunes, at the very bottom of the app tab.  Drag and drop the docs you want to move back and forth.
    Or use the clound.  Dropbox works fine.  Get the app in the store.
    To send them back out - reverse the process.

Maybe you are looking for