aspose file tools*
The moose likes Mac OS and the fly likes error message in terminal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "error message in terminal" Watch "error message in terminal" New topic
Author

error message in terminal

Scott Walker
Greenhorn

Joined: May 31, 2006
Posts: 12
im right at the beginning following a tutorial from a book.......when i type in javac MyFirstApp.java it comes up with a cannot be read error 1 message. I tried using textwrangler but the message still comes up. Am i supposed to save the file somewhere in particular because it is just on my desktop at the moment? I think it is a plain text document as well. I know someone had this problem before.....any suggestions? Thanks people.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

The Desktop isn't the best place for organizational purposes (I'd create a specific development folder), but that won't cause any other problems.

Be sure that the file is a plain text file. One way might be to type:

cat YourJavaFile.java

at the command line and make sure it looks correct.

Also, it would help when reporting problems to show us the exact error message that you are getting. Cut and paste from the Terminal window should work just fine.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Are you changing to the correct directory?

When you open Terminal, type cd (for "change directory") followed by a space and the path of the directory that contains your .java file, then hit return.

For example, I dump a lot of stuff under java/tests, so when Terminal opens, I type: cd java/tests


"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
Scott Walker
Greenhorn

Joined: May 31, 2006
Posts: 12
do i need to create a directory like java/tests to dump the stuff in? if so how do i do that? Thanks again for the advice guys.....i did warn you im right at the beginning haha and desperate to get started, take care
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

In Finder, navigate to where you want the new folder, then select "New Folder" from the File menu. Or instead of the File menu, you can use the "gear" action button at the top of Finder.

(Tip: At the top of Finder are also 3 view selection buttons: icons, list, and columns. To make sure the directory goes where you expect it to, avoid using the list view.)

As an alternative to using Finder, there's also a geek approach: The Unix command to make a directory in Terminal is mkdir followed by a space and the name of the directory (folder) you want to create.
Scott Walker
Greenhorn

Joined: May 31, 2006
Posts: 12
ok so at first it wouldnt recognise that id made a new directory in my documents folder....but then i tried the mkdir command in terminal and that seemed to work because my terminal prompt now has /java at the end.

but still when i type javac MyFirstApp.java i get this

error: cannot read: MyFirstApp.java
1 error

and when i tried typing cat MyFirstApp.java i get this

cat: MyFirstApp.java: No such file or directory


is there somewhere in particular i need to put my directory? This is so frutrating as i really dont know what im doing wrong and im so close to getting started! Thanks again for your help guys.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

It appears that your problems aren't with java at all but in dealing with the unix command line.

The error from the cat command means that the file is not in that folder. You need to get a handle on how to use the command line.

No special folder is required, but you must place the file in the folder you will compile it from. (It gets a bit more complicated when you start using packages, but one step at a time.)

I'd recommend finding a book or other resource on using the unix command line before proceeding.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Perhaps this one?
Scott Walker
Greenhorn

Joined: May 31, 2006
Posts: 12
thanks guys....i'll read it
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Good move! Without a working knowledge of using the command line, you'll find yourself struggling with simple issues that will just get in the way of trying to actually program.

I know it probably seems frustrating and you want to just dive into the programming aspect -- after all, that's the fun part! -- but learning your way around the command line will serve you well on all levels.

And by the way, recommending the book was not a way to say "go away and RTFM"! We're all still here to answer your questions and help you along.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Another good one is The Mac OS X Command Line: Unix Under the Hood by Kirk McElhearn.
Scott Walker
Greenhorn

Joined: May 31, 2006
Posts: 12
no worries.....i really appreciate your help so far. You're right though.....i dont know anything about using the unix command line.....but i will, see you soon
stella marsh
Greenhorn

Joined: May 16, 2006
Posts: 6
see my answer to your question about how i solved this...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error message in terminal