aspose file tools*
The moose likes Mac OS and the fly likes MAC OS X Set-Up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "MAC OS X Set-Up" Watch "MAC OS X Set-Up" New topic
Author

MAC OS X Set-Up

Simon Dean
Greenhorn

Joined: Mar 03, 2008
Posts: 7
Hi, two right-at-the-beginning questions:

1) Where do I save my .java files on the latest version of OS X?

2) How do I make sure Terminal is pointing at the right folder? At the moment, when I run "%javac myprogram.java", I get "no such job".

I've done absolutely no set-up as the book tells me it's not needed on OS X. My Unix skills are very low, so a pointer to a good beginner's site would also be appreciated.

Thanks for your time,
Simon.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

1) Wherever you want. I usually set up a project folder in my user area and work on my projects there.

2) Are you familiar at all with a unix command line? If not, you'll need to bone up on the bash shell.

The cd command changes your working directory (folder) and pwd shows you what it is.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Simon Dean
Greenhorn

Joined: Mar 03, 2008
Posts: 7
Thanks, Bear.

So if I can use any folder, how to I point the JVM to that folder so that it will find my progs?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

That's what the "current working directory" is all about. And of course, the classpath.

Have you done any command line Java work anywhere?
[ March 03, 2008: Message edited by: Bear Bibeault ]
Simon Dean
Greenhorn

Joined: Mar 03, 2008
Posts: 7
Nothing. Started out yesterday. )

I did do some C++ about 10 years ago, so I should be able to pick stuff up relatively quickly.
Simon Dean
Greenhorn

Joined: Mar 03, 2008
Posts: 7
Okay, that smiley was not meant to be like that!

If you like Sci-Fi, Bear - try Iain M. Banks, if you haven't already.
Simon Dean
Greenhorn

Joined: Mar 03, 2008
Posts: 7
Okay, I've read up on the sourcepath and the classpath and sorted everything out. Everything's hunky dory now and I've just compiled my first .class

Many thanks for your input, Bear. Much appreciated.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Very cool. Any unix command line reference should be fine for you to look at.

Windows, not so much.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11277
    
  59

Originally posted by Simon Dean:
2) How do I make sure Terminal is pointing at the right folder? At the moment, when I run "%javac myprogram.java", I get "no such job".
You should not be typing the "%" symbol at the start of the line. As Bear suggests, you will need to learn a bit about whatever unix shell you are using (typically Bash under OSX). Perhaps look for a tutorial on Bash on the internet to start with.

A little more information (which may be too much information for where you are right now - you decided for yourself) ...

Unix has the ability to run any job (process / application) in the foreground (where you get to see it, or the background. For example, from the command line, I could issue a command such as:
This will run in the foreground - that is, it while it is running, I cannot do anything else at that command prompt. You could, of course, open up multiple windows to run your various jobs in, but we also have the ability to put these programs into the background.

I have 2 options here:
  • I can type "Ctrl-Z" (which will suspend the running job), then type "bg" to put it into the background.
  • I can explicitly state at the time I start the job by putting an ampersand ("&") at the end of the line. Here are examples of the two in practice:

  • In the first instance I used the invisible "Ctrl-Z" to suspend the job (hence the "zsh: suspended" line) then put the job into the background, at which point it told me that job 1 ("[1]") has been "continued".

    In the second instance the job was immediately put into the background because I had an ampersand ("&") at the end of my line. I was told that this is now job number 5 and I was told it's process identification number (PID): 31298.

    NOTE: I did not type the "~%" in either of those cases - they are the prompts that let me know when I am supposed to start typing. If you are using Bash then your prompt may be a dollar sign ("$"). Another system I am running on has the prompt set to:

    Where it starts with the computer I am on, then tells me what directory I am in (the "~/src" where "~" is my home directory), then tells me who I am logged in as ("andrew") followed by a dollar sign.

    Anyway, back to my never ending saga. I put 2 jobs into the background. Let's prove it:

    So they both exist, and will both keep running forever (or until the computer stops - probably the second option ).

    If I want to bring either job back to the foreground so I can then interact with it again (or just kill it), I can use either the "fg" command (for foreground) or the "%" command (for those people who think that "fg" is too many characters ):

    In the first instance I told the system to bring to the foreground the most recent job that started with "while" (kind of silly since both jobs started with "while" - I could have just used "fg" on its own for the same effect).

    In the second instance I told the system to bring to the foreground job number 1.

    So when you typed "%java", the system thought you were trying to tell it to bring to the foreground some job that started with the command "java". And it was unable to find this job.

    Regards, Andrew


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Simon Dean
    Greenhorn

    Joined: Mar 03, 2008
    Posts: 7
    Many thanks, Andrew! Useful stuff.

    You know, I was thinking, Why is he telling me all this stuff NOW? It all became clear at the end. I feel like a right idiot that I didn't understand that the % in the Head First book was just the command prompt. But I bet I'm not the first or last to make that mistake...

    Thanks again for your time,
    Simon.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60046
        
      65

    LOL, it never occurred to me that you were actually typing the %. I just thought you were using it to indicate typing at the prompt that same way that most books do!
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    If you're looking for a good book (as I was when I switched to Mac), try The Mac OS X Command Line: Unix Under the Hood by Kirk McElhearn.
    [ March 03, 2008: Message edited by: marc weber ]

    "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
    Pauline McNamara
    Sheriff

    Joined: Jan 19, 2001
    Posts: 4012
        
        6
    A handy online reference is sometimes nice too. Have fun with Terminal, java and Head First.
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by Pauline McNamara:
    A handy online reference is sometimes nice too...

    Wow, that's a good one! Thanks for posting.
    Simon Dean
    Greenhorn

    Joined: Mar 03, 2008
    Posts: 7
    Many thanks to all of you for the extra tips!
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: MAC OS X Set-Up
     
    Similar Threads
    Startup Scripts in Linux
    Which way to run Windoze?
    new set up of IHS 7.x on AIX 6.1 . Need to redirect request from IHS to tomcat
    Eclipse cannot execute binary file.
    Classpath? Duh, what?