• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Total beginner here - Mac based Java - how do I find it/run scripts?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
So I have decided to jump in to Java. I have one problem though....I understand that Mac has Java already installed into OS X 10.4.11

However, I can't find it. Or at least, I can't find the JVM to test some scripts. I bought Head First Java, and I want to plug in one of their examples scripts....but where? I also don't see any Java folders in the Library.

I know there are no stupid questions, but I have been trying to figure this out for 3 days....and I feel stupid. Is it possible that it is not installed on my computer? I am about to move over to my desktop PC....but I'd rather have the portability of my Macbook.

Thanks so much for any help!
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!!!

I know nothing about Macs, but I always assumed that when they said java was already installed on them, they meant the JRE, not the JDK.

the JRE is what lets you RUN a java program. I.e. it's been compiled and you have the class files.

if you want to write and compile your own java, you may still have to install the JDK (Java Development Kit). But I can't address how you do that.
 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This link has a video...

http://blog.adsdevshop.com/2009/03/17/installing-the-jdk-16-on-mac-os-x-the-video/

Hope that helps,
Janeice
 
Marshal
Posts: 80612
467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

People will be keener to answer if you tell them what the question is about in the thread title.
 
R Arthur
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

People will be keener to answer if you tell them what the question is about in the thread title.



right you are....thanks Campbell...
 
Campbell Ritchie
Marshal
Posts: 80612
467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for changing it
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bring up a Terminal window, and enter javac at the command line.

If you get "command not found", the JDK is not installed.

If you get a usage message, you are good to go.
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. Using a good subject works. I would not have opened this topic if it hadn't had the word "Mac" in the subject.
 
R Arthur
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Bring up a Terminal window, and enter javac at the command line.

If you get "command not found", the JDK is not installed.

If you get a usage message, you are good to go.



Thanks Bear...

Looks like it is installed....so can you then tell me how I would test a script....I think I need to enter the script in a compiler? Where do I find that? Thanks for helping....I swear I'm not an idiot....I just gotta learn once....thanks so much.
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you are at the command line, you can just follow any tutorial on writing Java programs. There's nothing Mac-specific you need to worry about.

Essentially:
  • Write Java program in .java files using a text editor
  • Compile .java files using javac; creates .class files
  • Run program using java command


  • The devil is in the details. So pay attention to what the book is telling you.
     
    Campbell Ritchie
    Marshal
    Posts: 80612
    467
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Suggest a couple of stages before what Bear told you.

    mkdir javawork
    cd javawork

    That will create a nice directory called javawork (you can obviously give it any name you like) and you can keep all your Java safe in it; the line starting cd will take you directly to it.
     
    Java Cowboy
    Posts: 16084
    88
    Android Scala IntelliJ IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Have a look at Sun's Java tutorials. For the Mac, follow the Hello World tutorial for Solaris and Linux (Mac OS X is a Unix-like operating system, so it will be almost the same as for Solaris and Linux).
     
    R Arthur
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Bear Bibeault wrote:Once you are at the command line, you can just follow any tutorial on writing Java programs. There's nothing Mac-specific you need to worry about.

    Essentially:

  • Write Java program in .java files using a text editor
  • Compile .java files using javac; creates .class files
  • Run program using java command


  • The devil is in the details. So pay attention to what the book is telling you.



    Yea, I get the gist of steps 1, 2 and 3....I guess I just haven't grasped how one compiles .java files using javac......what program is used to compile?

    Anyway, I'll figure it out one way or another...thanks for the help!

    -Let me rephrase that....I thought I compiled in the JVM....and that's what I can't find...
     
    Janeice DelVecchio
    Bartender
    Posts: 1849
    15
    Eclipse IDE Spring VI Editor Java Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Okay.... here's another way to say this. I'm used to PC, but I think Macs are pretty much the same when it comes to this.....

    The Java Virtual Machine is what most people have on their computers. It's used, most notably, to run Java based applications as well as view Java content on web pages.

    The Java Developer Kit (JDK) is a bunch of stuff used by developers (like us) to compile programs. The programs are written in a text editor (if you're using the HeadFirst book I recommend NotePad++), or you can use a development environment like Eclipse.

    "javac" is the compiler you need to get the files you write in your text editor to turn into useful Java class files. In windows, there's a way to add the file to the known paths of the operating system. I think that video I linked to might have information on that for Macs.

    So you write a file, say "HelloWorld.java". How do you compile it?
    Type:


    ... at the command prompt while you're in the folder that has the file in it. If you're lucky and there are no errors , you get a class file. So now you have 2 files with different extentions (one java that you wrote, the other class... the compiled version). The JVM runs the class files. If you set your system properties correctly, you should then be able to type


    And your application will run.

    Hello World!! :-)



    Is this getting clearer? I remember it took me about a week to understand this whole thing when I started....
    -Janeice
     
    Jesper de Jong
    Java Cowboy
    Posts: 16084
    88
    Android Scala IntelliJ IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    R Arthur wrote:I guess I just haven't grasped how one compiles .java files using javac......what program is used to compile?


    The program that you use to compile Java source files to Java class files is javac, the Java compiler. It doesn't have a graphical user interface, it's a program that you use on the command line of the terminal window.

    The page About the Java Technology from Sun's tutorials explains it in detail, with pictures:

     
    R Arthur
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Janeice DelVecchio wrote:Okay.... here's another way to say this. I'm used to PC, but I think Macs are pretty much the same when it comes to this.....

    The Java Virtual Machine is what most people have on their computers. It's used, most notably, to run Java based applications as well as view Java content on web pages.

    The Java Developer Kit (JDK) is a bunch of stuff used by developers (like us) to compile programs. The programs are written in a text editor (if you're using the HeadFirst book I recommend NotePad++), or you can use a development environment like Eclipse.

    "javac" is the compiler you need to get the files you write in your text editor to turn into useful Java class files. In windows, there's a way to add the file to the known paths of the operating system. I think that video I linked to might have information on that for Macs.

    So you write a file, say "HelloWorld.java". How do you compile it?
    Type:


    ... at the command prompt while you're in the folder that has the file in it. If you're lucky and there are no errors , you get a class file. So now you have 2 files with different extentions (one java that you wrote, the other class... the compiled version). The JVM runs the class files. If you set your system properties correctly, you should then be able to type


    And your application will run.

    Hello World!! :-)



    Is this getting clearer? I remember it took me about a week to understand this whole thing when I started....
    -Janeice



    Thank you so much Janeice...it is becoming much clearer....that was very helpful!
     
    R Arthur
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Jesper Young wrote:

    R Arthur wrote:I guess I just haven't grasped how one compiles .java files using javac......what program is used to compile?


    The program that you use to compile Java source files to Java class files is javac, the Java compiler. It doesn't have a graphical user interface, it's a program that you use on the command line of the terminal window.

    The page About the Java Technology from Sun's tutorials explains it in detail, with pictures:



    Thanks Jesper....that helped me visualize it....this is a great forum....I hope I can repay someday....
     
    Janeice DelVecchio
    Bartender
    Posts: 1849
    15
    Eclipse IDE Spring VI Editor Java Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    YAY!!

     
    reply
      Bookmark Topic Watch Topic
    • New Topic