wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiler error" Watch "Compiler error" New topic
Author

Compiler error

Emile Indik
Greenhorn

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.
Emile
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?)

rc
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37897
    
  22
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
Greenhorn

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.

rc
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiler error
 
Similar Threads
Compile "MooseGreetings.java" Access Denied
Greenhorn with 64-bit can't set path
Moose Greetings
Save file without unwanted extensions
Trying to complie Moose Greetings