Reputation: 584
In C9, You have to configure your own runner/builder for Java. If asked for, I'll post my runner/builder if necessary.
I looked up an example script for using Scanner in Java. I use a site called Cloud9 for my code, scripts, etc., and I seem to have run into an issue.
I don't know if Cloud9 doesn't support it, but I got this example code for using Scanner, and it throws some weird error at me.
import java.util.Scanner;
class GetInputFromUser
{
public static void main(String args[])
{
int a;
float b;
String s;
Scanner in = new Scanner(System.in);
System.out.println("Enter a string");
s = in.nextLine();
System.out.println("You entered string "+s);
System.out.println("Enter an integer");
a = in.nextInt();
System.out.println("You entered integer "+a);
System.out.println("Enter a float");
b = in.nextFloat();
System.out.println("You entered float "+b);
}
}
Running GetInputFromUser.java
Enter a string
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1585)
at GetInputFromUser.main(GetInputFromUser.java:14)
Is it something to do with the C9 IDE or am I doing something wrong?
Upvotes: 0
Views: 145
Reputation: 2466
How does Cloud9 handle standard input? Because that's the error you get when Scanner hits end-of-file:
$ java GetInputFromUser </dev/null
Enter a string
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1516)
at GetInputFromUser.main(GetInputFromUser.java:14)
Upvotes: 1