Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input from commandline/java

Status
Not open for further replies.

gheorghe

Programmer
May 27, 2001
1
CA
when i insert the code to read input form commandline in my program, i get the errors:
1.class BufferedReader not found;
2.class InputStreamReader not found

Why is it that?
What should I do?

Here`s the code
--------------------------------------------------
import java.io.*;

//some code
System.out.print("Enter a word: ");

// open up standard input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String userName = null;

try {
userName = br.readLine();
} catch (IOException ioe) {
System.out.println("IO error trying to read the input!");
System.exit(1);
}

}

-----------------------------------------------
 
Sounds strange... is the import statement at the very beginning of your file, right after the package (if any - well, there should, but does not need to be one)?

If so, try to paste the following into a new file called TestIn.java and compile it, then tell me what error message you get...

import java.io.*;

public class TestIn
{
public static void main(String[] args)
{
System.out.print("Enter a word: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String userName = null;
try {
userName = br.readLine();
} catch (IOException ioe) {
System.out.println("IO error trying to read the input!");
System.exit(1);
}
}
}

Hope this helps... allow thyself to be the spark that lights the fire
 
Hi gheorghe,

I think you didn't set your classpath correctly since the java compiler didn't manage to read from the java.io package.

Maybe you would like to paste out your classpath settings as well?

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Hello all,

i'm having problems when trying to pass a parameter of type variant of my client app to a vc++ server app. Can anybody tells me how can i do that with sun jdk ?

Thanks in advance

Thor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top