// 
//     Licensed to the Apache Software Foundation (ASF) under one
//     or more contributor license agreements.  See the NOTICE file
//     distributed with this work for additional information
//     regarding copyright ownership.  The ASF licenses this file
//     to you under the Apache License, Version 2.0 (the
//     "License"); you may not use this file except in compliance
//     with the License.  You may obtain a copy of the License at
// 
//       http://www.apache.org/licenses/LICENSE-2.0
// 
//     Unless required by applicable law or agreed to in writing,
//     software distributed under the License is distributed on an
//     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
//     KIND, either express or implied.  See the License for the
//     specific language governing permissions and limitations
//     under the License.
//

= DevFaqOutputWindow
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqOutputWindow
:description: Apache NetBeans wiki DevFaqOutputWindow
:toc: left
:toc-title:
:syntax: true

== How do I create my own tab in the output window and write to it?

NetBeans contains classes that make writing to the output window very simple - you don't have to worry about components, you just get an instance of a thing called `InputOutput`, which has methods `getOut()` and `getErr()` that return `OutputStream`s.  There is a utility class, `IOProvider` that can supply `InputOutput` objects - you pass it a string name that should be shown on the output tab, and a boolean (whether or not it should reuse an existing tab with the same name if there is one).  So, hello world code for the output window looks like this:

[source,java]
----

InputOutput io = IOProvider.getDefault().getIO ("Hello", true);
io.getOut().println ("Hello from standard out");
io.getErr().println ("Hello from standard err");  //this text should appear in red
io.getOut().close();
io.getErr().close();
----

It is important to close the output streams when you are done with them - output is written to a memory mapped file, which cannot be deleted if the stream is still open - and the tab title will remain boldfaced until the streams are closed, which helps indicate to the user that the process has finished.

-- Main.timboudreau - 10 Jun 2006

Note: For platform based applications to correctly use InputOutput and IOProvider an Output Window implementation must be available and enabled.  Follow the below steps to be sure you include everything to allow the output window and tabs to be used and shown.

1. Open your module projects properties.  (Right click the project and select properties).
2. Select libraries
3. Check to see if 'I/O APIs' is in the dependency list.
4. If it is not it needs to be added.

To add 'I/O APIs'

1. Choose 'Add'  from 'Module Dependencies'
2. Select 'I/O APIs' from the list
3. Press OK

To force 'Output Window'  (the implementation of the tabbed output window) to be enabled,

1. Choose 'Add' from 'Required Tokens'
2. Pick =org.openide.windows.IOProvider=
3. Press OK

Note: this shall not be necessary in the current 6.0 trunk version..

Relevent to 6.0: If the dependencies do not show up in the selection list check the 'Module Suite' to make sure they have not been excluded from the platform.

1. Right click on the module suite
2. Click Properties
3. Go to Libraries
4. Locate the platform 'Clusters and Modules'
5. Make sure I/O API is checked
6. Make sure Output Window is checked
7. Click OK

Hint: It is sometimes helpful to call InputOutput.select() to make sure the tab is made visible in the output window.

See link:http://plugins.netbeans.org/plugin/39695/?show=true[here] for a plugin that has a convenient class for all output purposes.

=== Apache Migration Information

The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.

This page was exported from link:http://wiki.netbeans.org/DevFaqOutputWindow[http://wiki.netbeans.org/DevFaqOutputWindow] , 
that was last modified by NetBeans user Javydreamercsw 
on 2011-08-01T14:18:43Z.


*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.
