This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 49
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: 7549
    
  18

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?
Articles by Winston can be found here
Andrzej Borucki
Ranch Hand

Joined: Aug 24, 2013
Posts: 49
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: 49
http://illegalargumentexception.blogspot.com/2010/09/java-systemconsole-ides-and-testing.html
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7549
    
  18

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: 49
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
Help with runtime.exe and javac from command line
reading byte array
access .txt files under the particlar parent directory
How do I package stuff?
File Listing