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 trial

Java Java Basics Getting Started with Java Strings and Variables

Emil Wallgren
Emil Wallgren
11,737 Points

IntelliJ IDEA problem


I'm trying to run this code on IntelliJ IDEA. But it's showing an error message. Any ideas why?

package com.emilwallgren;
import java.io.Console;

public class Main {

    public static void main(String[] args) {
    // write your code here
        Console console = System.console();


the error message is:

Exception in thread "main" java.lang.NullPointerException at com.emilwallgren.Main.main(Main.java:10) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Process finished with exit code 1

1 Answer

Ken Alger
Ken Alger
Treehouse Teacher


IntelliJ does not support console normally. Take a look at the 'scanner' class instead. Mr. Dennis discusses this a bit in his new course, Local Development Environments.

Hope it helps and happy coding,