darkwing_duck
April 4th, 2009, 08:21 AM
Hi, and thanks for visiting this thread....
I am new to Java in Ubuntu and I'm trying to compile a simple program to do some console input/output.
Here's my watered-down code...
import java.io.Console;
public class console_io
{
public static void main(String[] args)
{
Console console = System.console();
if (console == null)
{
System.err.println("No console.");
System.exit(1);
}
}
}
Here's the compile-time error I get...
username@computer:~$ javac console_io.java
----------
1. ERROR in console_io.java (at line 1)
import java.io.Console;
^^^^^^^^^^^^^^^
The import java.io.Console cannot be resolved
----------
2. ERROR in console_io.java (at line 7)
Console console = System.console();
^^^^^^^
Console cannot be resolved to a type
----------
3. ERROR in console_io.java (at line 7)
Console console = System.console();
^^^^^^^
The method console() is undefined for the type System
----------
3 problems (3 errors)username@computer:~$
I'm thinking this has to do with my Java install, but I'm not knowledgeable about that kind of stuff, any help resolving this would be much appreciated.
P.S. - I read the FAQ for this forum.
Thanks in advance.
I am new to Java in Ubuntu and I'm trying to compile a simple program to do some console input/output.
Here's my watered-down code...
import java.io.Console;
public class console_io
{
public static void main(String[] args)
{
Console console = System.console();
if (console == null)
{
System.err.println("No console.");
System.exit(1);
}
}
}
Here's the compile-time error I get...
username@computer:~$ javac console_io.java
----------
1. ERROR in console_io.java (at line 1)
import java.io.Console;
^^^^^^^^^^^^^^^
The import java.io.Console cannot be resolved
----------
2. ERROR in console_io.java (at line 7)
Console console = System.console();
^^^^^^^
Console cannot be resolved to a type
----------
3. ERROR in console_io.java (at line 7)
Console console = System.console();
^^^^^^^
The method console() is undefined for the type System
----------
3 problems (3 errors)username@computer:~$
I'm thinking this has to do with my Java install, but I'm not knowledgeable about that kind of stuff, any help resolving this would be much appreciated.
P.S. - I read the FAQ for this forum.
Thanks in advance.