wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Compiler error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiler error" Watch "Compiler error" New topic

Compiler error

Emile Indik

Joined: Jan 29, 2011
Posts: 2
Hello, I'm working with Mac OS X 10.5.8. I followed the guide on this website to create my first java program, and saved a file called "MooseGreetings.java" with this text copied from the guide:

I then proceeded to open a terminal window and type "javac MooseGreetings.java"
It had one error, it could not read it. I neglected doing the PATH thing, if that's the problem I'd be gracious for a short guide on how to do that. If not, any other thoughts would help.
Thank you.
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
Welcome to JavaRanch. And welcome to Java.

One of the great things about java is that its error messages tend to be very informative; once one understands what to look for, the error messages tend to tell you exactly what is wrong and where.

One of the great things about people that read this forum is that, among us, we've all made most of the mistakes people are likely to make, and recognize the error messages, etc.

So please, now and in general: don't paraphrase the error message(s). Tell us what it says. Because you're learning, what you think it's talking about may be wrong, and we can correct that most easily if we have the information from the compiler (and, as you progress through your learning, the runtime).

"It had one error, it could not read it" just has too many 'its' (itss?)

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38064
Welcome again

I thought Macs came with Java™ already installed. Are you sure it is a PATH problem?

As for setting the PATH, I googled and found this. It appears very similar to how one does it on Linux.
Emile Indik

Joined: Jan 29, 2011
Posts: 2
Thanks for the reply. The Terminal message said
"error: cannot read: MooseGreetings.java
1 error"
When I inputted something random, like "sdkfchsdn.java", the same message, with "MooseGreetings.java" replaced by "sdkfchsdn.java" came up.
I don't think I'm even on the right track here. It probably has something to do with skipping the PATH step.
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
I don't think it has to do with skipping the "PATH step". I am not familiar with the Mac, but it appears the compiler is attempting to read the file and cannot. That suggests that the compiler is, in fact, being invoked, and setting PATH is for ensuring that the command can invoke the compiler.

This would happen if your default directory is not the same one that contains your MooseGreetings.java file. Assuming the Mac terminal window uses Unix-like commands, execute "ls" and see if the source file is there. If not, find out where you put it, and do a "cd" (for change directory) to that directory.

Then try "javac" again.

It is sorta covered in the JavaRanch Style Guide.
subject: Compiler error
Similar Threads
Greenhorn with 64-bit can't set path
Trying to complie Moose Greetings
Compile "MooseGreetings.java" Access Denied
Moose Greetings
Save file without unwanted extensions