Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDominik Huber
4,631 PointsConsole console = System.console() --> Why is it not working in my IDE?
Hi,
I took this course the 2nd time. Now doing everything without workspace but with my own IDE (Intellij). So now I encountered a problem:
I cant use Console console = System.console() --> It just won't work. Can anyone explain me why it's not working outside of the IDE but it's working on the teamtreehouse workspace?
I have a fix for this:
Scanner scanner = new Scanner(System.in); System.out.println("Please enter a letter: "); String guessAsString = scanner.next();
But I want to understand why it's not usable in IDE.
I found t his: http://stackoverflow.com/questions/4644415/java-how-to-get-input-from-system-console
I'm wondering what's meant by "usable only outside IDE" ? Where else could you write a programm?
Thx!
2 Answers
Jeremy Hill
29,567 PointsI could not get it to work in my IDE either. I usually use a Scanner object from importing java.util.Scanner.
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsYou can compile and run the program in Unix console/terminal with Console console
code.
That is exactly what they have in Workspaces: Unix console with Bash.
Depending on your OS: you can one start terminal, download files from the workspace and run just like in workspace:
javac Class.java
and then java Class
If you want to learn why Console
is not working in IDE, try for example this discussion:
http://stackoverflow.com/questions/26470972/trying-to-read-from-console-java
See the best answer voted: guy gives pretty explicit explanation