aspose file tools*
The moose likes Beginning Java and the fly likes Reading from console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reading from console" Watch "Reading from console" New topic
Author

Reading from console

Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 174
Hi,

I am trying this but it is not reading properly

System.out.print("Enter Siebel UserId: ");
Scanner scanner = new Scanner(System.in);

String sblUId = scanner.next();

System.out.println(sblUId);

System.out.print("Enter Siebel Password: ");
String sblPwd = scanner.nextLine();

System.out.println(sblPwd);

System.out.print("Enter Inquira UserId: ");
String inqUId = scanner.nextLine();

System.out.println(inqUId);

System.out.print("Enter Inquira Password: ");
String inqPwd = scanner.nextLine();

System.out.println(inqPwd);


Please help
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

What do you mean by "not reading properly"? You have to give us more to go on than that. What input are you giving it, and what results are you getting? Also, it's a good idea to wrap code in code tags, even when it's relatively simple code like this.
Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 174
Hi,

Thanks for the advice.

Here is the program. Please run it to see what i am telling is the problem

Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Jacob Sonia, please read http://faq.javaranch.com/java/TellTheDetails

No one would able to help you till you tell the details. Even without running, I see that you code would not work, because you would get an error in the line 5 something like "Scanner cannot be resolved to a type". Is this your problem?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

Hi Jacob,

Misha is right on both counts. 1. You have to import java.util.Scanner for the program to compile, and 2. you have to explain what problems are having; you can't expect people who are helping you out of the goodness of their hearts to run your programs to figure out your problems for you.

That said, I ran your program anyway. With the addition of that missing import statement, it seems to run fine. What problem are you having?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reading from console