File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't read

 
Kevin Tysen
Ranch Hand
Posts: 255
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your classpath settings. Your system needs to know where to find 'javac'.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the file is open and locked in another porgram.

You can check capitalization, but I think you got that right.

Is there a package statement at the top? If there is compiling from the correct directory becomes trickier.

Mark
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajesh Chandra
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either check out your class name or you put the java file in bin directory and try compiling it
regs Rajesh
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...

...userName$
...userName$ cd java/tests
.../java/tests userName$ javac MyFile.java
.../java/tests userName$ java MyFile
 
Kevin Tysen
Ranch Hand
Posts: 255
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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."
 
Grant Gainey
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...

Grant
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Grant Gainey:
...OS/X is a BSD Unix derivative. Almost enough to make me go back to the Mac for my next machine...

I recently switched. You won't regret it!
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Grant Gainey
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Grant

(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...)
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Grant Gainey:
... I bought my first Mac in 1986. But it became harder and harder to justify having one as my "primary" machine...

Yeah, the 90's were troubled for Apple. I didn't own a computer in the 80's (when I was more interested in guitars), and I couldn't justify a Mac until they started turning things around again.

Although I obviously like doing certain things with computers, I've never liked the machines themselves. The Mac is Different. This is the first computer I've really enjoyed.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you have completely hijacked this thread.

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

Mark
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic