java.util.scanner - Java with Sublime Text - Scanner not working? -
i trying learn java, , i've started.
i want run code found online:
import java.util.scanner; // needed scanner /** java program demonstrates console based input , output. */ public class myconsoleio { // create single shared scanner keyboard input private static scanner scanner = new scanner( system.in ); // program execution starts here public static void main ( string [] args ) { // prompt user system.out.print( "type data program: " ); // read line of text user. string input = scanner.nextline(); // display input user. system.out.println( "input = " + input ); } // end main method } // end myconsoleio class
however error:
type data program: exception in thread "main" java.util.nosuchelementexception: no line found @ java.util.scanner.nextline(scanner.java:1540) @ myconsoleio.main(myconsoleio.java:17) [finished in 0.9s exit code 1]
i running code in sublime text 2, directly in editor, pressing cmd+b.
i'm not sure sublime text, programm looks correct. ran in netbeans 8.0.1 , works fine. looks problem in how sublime runs java programs.
try compile , run standard java compiler , run tools. further details read this: http://www.oracle.com/technetwork/java/compile-136656.html
Comments
Post a Comment