Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes cannot read error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot read error" Watch "cannot read error" New topic

cannot read error

Sartaj Syed

Joined: Nov 11, 2001
Posts: 22
When I try to compile the following file Iget the error message Cannot read. It does not seem to be a path problem as other files in the same directory are compiling,
import java.awt.*;
public class FS1 extends Frame{
//Build and add Panel3.
Panel p3 = new Panel();
Label L1 = new Label("Project Continued on Revision #");
TextField T1 = new Textfield);
add(p3, BorderLayout.SOUTH);
public static void main(string args[]){
FS1 fs = new FS1();
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Are you sure you named the file and not something like or
ps there are numerous compile errors in this file.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Also be sure that you saved it as a .txt file and not accidently as a .doc format.
Sartaj Syed

Joined: Nov 11, 2001
Posts: 22
I use JEdit that saves all files as .java.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
It's nice when the code is formatted.

Problem: TextField is TextField, not Textfield. And you're missing the opening parenthesis.
Another Problem: Your main() is outside of the class programming block! And you have one too many closing brackets. Move main() into class programming block. Remove extra closing bracket.
Another Problem: String is String, not string. See the parameters of your main().
Another Problem: gray is gray, not grey.
Another Problem: setVisible(boolean) is setVisible(boolean), not setvisible(boolean).
Make these corrections, and it will compile.
Good Luck!
[ January 15, 2002: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
It is sorta covered in the JavaRanch Style Guide.
subject: cannot read error
It's not a secret anymore!