aspose file tools*
The moose likes Beginning Java and the fly likes can't read Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "can Watch "can New topic
Author

can't read

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
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

Joined: Jul 10, 2002
Posts: 214

Check your classpath settings. Your system needs to know where to find 'javac'.


SCJP, SCWCD
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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...


There is no emoticon for what I am feeling!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61006
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rajesh Chandra
Ranch Hand

Joined: Jun 13, 2005
Posts: 55
Either check out your class name or you put the java file in bin directory and try compiling it
regs Rajesh
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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


"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
Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
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

Joined: Oct 16, 2005
Posts: 65
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


In Theory, there is no difference between theory and practice.<br />In Practice, there is no relationship between theory and practice.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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

Joined: Aug 31, 2004
Posts: 11343

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

Joined: Oct 16, 2005
Posts: 65
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

Joined: Aug 31, 2004
Posts: 11343

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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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

Joined: Aug 31, 2004
Posts: 11343

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
 
subject: can't read