I typed in a simple program to begin my java programming days (I'm just starting with java). I typed in javac and the program name (also the class name), which is MyFirstApp, like this: javac MyFirstApp.java and got an error message: Can't read file. I typed the file just like in page 6 of the book Head First Java but I keep getting the message. I wonder what's wrong.
Sounds like it's finding javac, since the error message is from the compiler. Double-check the name of your file. It may be case sensitive, so FooBar.java, foobar.java and Foobar.java are three different names...
In answer to your cross-posted question, no this is not an OS X Java bug. It works fine on my system.
Be sure that you are cd-ing to the correct folder, and that the folder structure reflects any package hierarchy.
It might be best if you showed us the complete code of your class (please use UBB code tags to preserve the formatting), the exact command line that you are using, and the exact wording of the error message.
Since you're using a Mac (as indicated in a cross-post), the Java SDK should be installed and ready to go. You shouldn't have to worry about any PATH settings.
My guess is that you're just not changing to the correct directory. As Bear said above, "Be sure that you are cd-ing to the correct folder." When you start Terminal, type "cd" (without quotes) to Change Directory, followed by a space and the path for the folder that your .java file is in (using forward slashes between folders). For example, at your "userName$" prompt...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Oct 12, 2005
I did the cd command like you said. It worked! Thank you everybody! In the Mac terminal, what computer language do you use? Is that DOS or Unix commands or part of java language or what? As we say here in Japan, "Mata yoroshiku onegai shimasu."
Originally posted by Kevin Tysen: I did the cd command like you said. It worked! Thank you everybody! In the Mac terminal, what computer language do you use? Is that DOS or Unix commands or part of java language or what?
OS/X is a BSD Unix derivative. Almost enough to make me go back to the Mac for my next machine...
In Theory, there is no difference between theory and practice.<br />In Practice, there is no relationship between theory and practice.
Originally posted by Kevin Tysen: ...In the Mac terminal, what computer language do you use? Is that DOS or Unix commands or part of java language or what? ...
In OS 10.3 and 10.4, the default shell for Terminal is bash (Bourne-Again SHell). The default for earlier OS X versions is tcsh (TENEX C SHell). As of 10.2, zsh can also be run.
This is straying into Mac-specific territory, and JavaRanch has a separate board for that. [ October 28, 2005: Message edited by: marc weber ]
Joined: Oct 16, 2005
Originally posted by marc weber:
I recently switched. You won't regret it!
It would be switching back, actually. I bought my first Mac in 1986. But it became harder and harder to justify having one as my "primary" machine, since I started using Java as my primary development environment in 1997. Eventually, I gave up and went over to The Dark Side.
Now, with four people in the house at the moment, there are two iMacs, two XP boxes, a running Fedora Core 3...and Brutus, the (smokin' hot!) PPC 9500. Woo!
I really can't justify another CPU - even if the new dual-core G5s look...sweet. Very sweet. Sigh.
(are we gonna get moved to Mac-land? Probably - especially if we continue down this particular trail. I follow threads where e'er they lead...)
I had the original Mac 128K in 1984. I moved to PCs in 1992, and will never go back. I am having much more fun on PCs. I keep trying the Macs, but I just feel so limited with the number of applications available. Lets see, I can Itunes, IMovies, IBrowse, and IWordProcess and ISpreadsheet. Does that cover everything? ;0
Originally posted by Mark Spritzler: ... I am having much more fun on PCs. I keep trying the Macs, but I just feel so limited with the number of applications available...
Hmmm... I suppose these things happen.
It's true that Macs (in their current state) are not the best choice for everyone. But I think that's changing. The only application I would have liked to continue using on Mac is Sony's Acid Pro (for loop-based music production). But I suspect that once I get up to speed on GarageBand (or Logic Express or Cubase), I'll be more than happy to leave Acid behind.
On a Java note, I've just started a Swing project, and it looks SO cool on the Mac!