It's not a secret anymore!
The moose likes Beginning Java and the fly likes hello world code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "hello world code" Watch "hello world code" New topic

hello world code

tny shariff

Joined: Sep 18, 2004
Posts: 7
dear all,
im starting my 1st program java,i saved it as "". but i cant compile it- the error statement is error: cannot read: (im using console window)
pls help..

* The HelloWorldApp class implements an application that
* displays "Hello World!" to the standard output.
public class HelloWorldApp {
public static void main(String[] args) {
// Display "Hello World!"
System.out.println("Hello World!");

p/s:- i compile it as javac

error msg:error : cannot read:
1 error
Parth Sagdeo
Ranch Hand

Joined: Mar 18, 2004
Posts: 40
Did you save the file as Is it in the right directory?
[ April 29, 2005: Message edited by: Parth Sagdeo ]
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
are you comppiling from the directory where you have the java file???
javac may be in the classpath but you still have to navigae to the directory where you have the java file and then try compiling..

Life called,so here I am.<br />Cheers<br />Niki.:-)
Giovanni De Stefano
Ranch Hand

Joined: Aug 17, 2004
Posts: 154
it seems that the file is not there or it has a different name!
You are using the command line, aren't you? If you can type java from anywhere, then your JAVA_HOME environment variable is set you have to navigate to the directory where you actually saved your file, I would suggest c:\ just to be sure you don't get lost!
Once you have java in your path AND you are in the same directory where your java file is, then javac will do just fine, after that (if there are no errors) you will find HelloWorld.class, type java HelloWorld and you are set! :-)
P.S. The error you reported says that the compiler cannot find the source file, this means that you are in the wrong directory (just type dir and look for OR you used something like Notepad which added the extension .txt to your java file (in this case you have
Good luck!

SCJP 1.4
Ramakrishna Nalla
Ranch Hand

Joined: Apr 21, 2005
Posts: 61
Hi shariff welcome to JAVA world:
Comming to YOUR problem..As you using command line...(Linux or Windows ??)...
I am assuming windows...

Don't use notepad to write java programs, because it add extention .txt to your given name..for examle if you give filename: then it will be If you prefer to notepad only...then save file with double codes like "" and that's it.

That's problem only mistake of filename...better try in command line..

Command line: if u use directory C:\JAVAPRG\> ...then:

Press ENTER...
write your program and save it and exit...and now...
stay in same directory
Press ENTER....
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I might agree that the DOS text editor is better than NotePad. However, I'd go a bit further and suggest that you download a REAL text editor like TextPad.

Also, let us know if the suggestions above helped at all.


Java API Documentation
The Java Tutorial
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
Welcome to JavaRanch, Tny Shariff. How do you pronounce your first name?

You might consider returning a thread that you start to see responses there and clarify any questions the responders ask before starting another almost identical thread.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: hello world code
It's not a secret anymore!