wood burning stoves*
The moose likes I/O and Streams and the fly likes Exception at printf() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Exception at printf()" Watch "Exception at printf()" New topic
Author

Exception at printf()

Andrzej Borucki
Ranch Hand

Joined: Aug 24, 2013
Posts: 42
I wrote simple program:

In System.console().printf("something") is error, despite in Eclipse I check "Allocate console" in Common tab in Run/Debug configurations
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7081
    
  16

Andrzej Borucki wrote:In System.console().printf("something") is error, despite in Eclipse I check "Allocate console" in Common tab in Run/Debug configurations

It would be useful to know what the error is. Is it, for example, a NullPointerException?

I'm pretty sure that the "console" referred to in the tab you mentioned is Eclipse's console, not a Console object, which has only been around since 1.6. I also understand that some IDE's use a background Thread for it, which is incompatible with System.console().

My suggestion: look at the example code in the java.io.Console docs, and use that; and if it doesn't work in Eclipse, try running your program from the command line instead.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Andrzej Borucki
Ranch Hand

Joined: Aug 24, 2013
Posts: 42
If I create runnable jar, it printf() OK, but with Eclipse IDE is java.lang.NullPointerException
How to write common code - System.console() for outside Eclipse and Eclispe console for inside IDE?
Andrzej Borucki
Ranch Hand

Joined: Aug 24, 2013
Posts: 42
http://illegalargumentexception.blogspot.com/2010/09/java-systemconsole-ides-and-testing.html
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7081
    
  16

Andrzej Borucki wrote:http://illegalargumentexception.blogspot.com/2010/09/java-systemconsole-ides-and-testing.html

Well discovered. That's what we like to see.

Winston
Andrzej Borucki
Ranch Hand

Joined: Aug 24, 2013
Posts: 42
Or simply
System.out - black text in Eclipse console
System.err - red text in Eclipse console
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception at printf()
 
Similar Threads
access .txt files under the particlar parent directory
reading byte array
File Listing
Help with runtime.exe and javac from command line
How do I package stuff?