This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 235334 - cannot run the console from within Netbeans
Summary: cannot run the console from within Netbeans
Status: RESOLVED DUPLICATE of bug 68770
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 7.0.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-30 18:55 UTC by thufir
Modified: 2013-09-17 09:25 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description thufir 2013-08-30 18:55:32 UTC
The following runs fine from the CLI:

thufir@dur:~$ 
thufir@dur:~$ java -jar NetBeansProjects/WeatherTelnet/dist/WeatherTelnet.jar 
-----------------------------------------------------------------------------
*               Welcome to THE WEATHER UNDERGROUND telnet service!            *
------------------------------------------------------------------------------
*                                                                            *
*   National Weather Service information provided by Alden Electronics, Inc. *
*    and updated each minute as reports come in over our data feed.          *
*                                                                            *
*   **Note: If you cannot get past this opening screen, you must use a       *
*   different version of the "telnet" program--some of the ones for IBM      *
*   compatible PC's have a bug that prevents proper connection.              *
*                                                                            *
*           comments: jmasters@wunderground.com                              *
------------------------------------------------------------------------------

Press Return to continue:
^Cthufir@dur:~$ 
thufir@dur:~$ 
thufir@dur:~$ cat NetBeansProjects/WeatherTelnet/src/weathertelnet/WeatherTelnet.java 
package weathertelnet;

import java.io.Console;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.SocketException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.net.telnet.TelnetClient;

public final class WeatherTelnet implements Runnable {

    @Override
    public void run() {
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    consoleOutput();
                } catch (SocketException ex) {
                    Logger.getLogger(WeatherTelnet.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(WeatherTelnet.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }).start();


        new Thread(new Runnable() {

            @Override
            public void run() {
                consoleInput();
            }
        }).start();
    }

    public void consoleInput() {
    }

    public void consoleOutput() throws SocketException, IOException {
        TelnetClient tc;
        tc = new TelnetClient();
        tc.connect("rainmaker.wunderground.com", 3000);

        InputStream inputStream = tc.getInputStream();

        char ch = (char) inputStream.read();

        while (255 > ch && ch >= 0) {
            PrintWriter foo = c.writer();
            foo.print(ch);
            foo.flush();
            ch = (char) inputStream.read();
        }
    }
    private Console c;

    public WeatherTelnet() {
        c = System.console();
        run();
    }

    public static void main(String[] args) {
        new WeatherTelnet();
    }
}
thufir@dur:~$ 
thufir@dur:~$ 




but netbeans gives this result:



init:
deps-jar:
Created dir: /home/thufir/NetBeansProjects/WeatherTelnet/build
Updating property file: /home/thufir/NetBeansProjects/WeatherTelnet/build/built-jar.properties
Created dir: /home/thufir/NetBeansProjects/WeatherTelnet/build/classes
Created dir: /home/thufir/NetBeansProjects/WeatherTelnet/build/empty
Created dir: /home/thufir/NetBeansProjects/WeatherTelnet/build/generated-sources/ap-source-output
Compiling 1 source file to /home/thufir/NetBeansProjects/WeatherTelnet/build/classes
Copying 1 file to /home/thufir/NetBeansProjects/WeatherTelnet/build/classes
compile:
run:
Exception in thread "Thread-0" java.lang.NullPointerException
	at weathertelnet.WeatherTelnet.consoleOutput(WeatherTelnet.java:53)
	at weathertelnet.WeatherTelnet$1.run(WeatherTelnet.java:21)
	at java.lang.Thread.run(Thread.java:724)
BUILD SUCCESSFUL (total time: 0 seconds)



see also:


http://stackoverflow.com/questions/2430080/
Comment 1 thufir 2013-08-30 19:03:35 UTC
on netbeans mailing list, I was directed to this bug:


https://netbeans.org/bugzilla/show_bug.cgi?id=68770
Comment 2 Jiri Prox 2013-09-02 05:53:47 UTC

*** This bug has been marked as a duplicate of bug 68770 ***
Comment 3 Tomas Zezula 2013-09-17 09:25:29 UTC
The problem is that terminal requires pseudo tty.