Results 1 to 12 of 12
  1. #1

    Ciwan's Avatar
    Member Since
    Oct 30, 2009
    Location
    The Milky Way
    Posts
    136
    Specs:
    iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard
    Exclamation Coding C++ and Java
    Hi Guys

    I am a university student, and we are currently learning how to program in C++ and Java.

    How can I Program Java and C++ Code on my iMac ? What do I need ? Are there settings that need to be played with ?

    let's assume I have a file called { mycode.java } how can I run that code ?

    I would greatly appreciate any help.

    Thank You.
    "Animals, whom we have made our slaves, we do not like to consider our equal." .... Charles Darwin (1809 - 1882)

  2. #2

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    The JDK should be pre-installed. Open up Terminal and type the following (assuming the java code is found in mycode.java):
    Code:
    javac <directory where mycode java file is>/mycode.java
    Press enter and that will compile your code. Then type the following to run it:
    Code:
    java <dir where mycode class file is>/mycode
    Note that when running java to run the class, there is no extension.

    As for C++, install the Xcode dev tools off of the install discs (I think it's disc 1) or get them from the Apple developer site.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  3. #3

    Ciwan's Avatar
    Member Since
    Oct 30, 2009
    Location
    The Milky Way
    Posts
    136
    Specs:
    iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard
    Will the JDK be the latest version ?

    Thanks
    "Animals, whom we have made our slaves, we do not like to consider our equal." .... Charles Darwin (1809 - 1882)

  4. #4

    Ciwan's Avatar
    Member Since
    Oct 30, 2009
    Location
    The Milky Way
    Posts
    136
    Specs:
    iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard
    Unhappy
    I can't find anything called Development Tools !

    There is a program called { XCode 3.2.4 and iOS SDK 4.1 } which I have downloaded.

    Though I'm not sure if that is what I was suppose to download !

    Also there is a link to Developer Downloads, and once I click that I get a long list of stuff, but none of them is { XCode Development Tools }

    I'm stuck
    "Animals, whom we have made our slaves, we do not like to consider our equal." .... Charles Darwin (1809 - 1882)

  5. #5

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    Xcode = the developer tools. If there was any confusion, that was my fault.

    I have Java 1.6.0_20 on my machine. You can always check yours by executing "java -version" at the CLI. That will give you the version of the Java runtime and I assume that the JDK would be the same version.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  6. #6

    Ciwan's Avatar
    Member Since
    Oct 30, 2009
    Location
    The Milky Way
    Posts
    136
    Specs:
    iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard
    Thanks vansmith

    Just to clarify, as I have already mentioned, I have downloaded the { XCode 3.2.4 and iOS SDK 4.1 } And I understand you've said the XCode is the Developer Tools, but mine has iOS SDK with it !!!

    Would that cause any issues ? Plus how big is it ? Cause I don't like having stuff that I won't need.

    Finally I asked my lecturer and he said we're using Java version 6. And my version of Java is the same as yours !! { 1.6.0_20 } does that mean we are way behind on Java Updates ?

    Thanks
    "Animals, whom we have made our slaves, we do not like to consider our equal." .... Charles Darwin (1809 - 1882)

  7. #7

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    As you can see here, Java 6 refers to version 1.6.0. Yes, the version numbers are weird. Your best bet would be to clarify with your prof and ask them whether or not you have the required tools.

    I have no idea how much extra is installed if you install the iOS SDK. AFAIK though, there is a version of the Xcode dev tools that doesn't have the iOS SDK.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  8. #8

    Ciwan's Avatar
    Member Since
    Oct 30, 2009
    Location
    The Milky Way
    Posts
    136
    Specs:
    iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard
    OK Thanks Vansmith.

    One last question, say I have a C++ file called { mycode.cpp }

    How do I run it ? do I open the terminal and type cc mycode.cpp ? or is this different ?

    Thanks
    "Animals, whom we have made our slaves, we do not like to consider our equal." .... Charles Darwin (1809 - 1882)

  9. #9

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    I'm not a GCC pro but this looks like it might help.

    As an aside, isn't your prof supposed to teach you how to do all of this?
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  10. #10

    Ciwan's Avatar
    Member Since
    Oct 30, 2009
    Location
    The Milky Way
    Posts
    136
    Specs:
    iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard
    LOL He has, but on Windows

    I'll read the article and see whether I can get it to work.
    "Animals, whom we have made our slaves, we do not like to consider our equal." .... Charles Darwin (1809 - 1882)

  11. #11

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,782
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    The commands to compile a Java program are the same across OS. The GCC commands should be the same as well. That is irrelevant though if your prof doesn't use GCC.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  12. #12

    Zoolook's Avatar
    Member Since
    Sep 24, 2006
    Location
    Brooklyn, New York
    Posts
    2,756
    Specs:
    15" MacBook Pro, i7 2.66Ghz, 8GB RAM, 512GB SSD; iPad 3, iPhone 5
    Quote Originally Posted by Ciwan View Post
    LOL He has, but on Windows
    That's pretty ironic, considering JAVA is platform agnostic.

    Anyway, you might want to check out this resource

    Switching to the Mac for the Java Developer, Part 1 &mdash; Developer.com
    In the land of the blind, the one-eyed man is stoned to death.
    - Joan D. Vinge


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java for Mac OS X 10.6 Update 17 latest java version?
    By Applet in forum OS X - Operating System
    Replies: 2
    Last Post: 09-12-2014, 03:07 AM
  2. From where should I disable Java (Java preferences or Safari?)
    By dacoolest in forum OS X - Operating System
    Replies: 10
    Last Post: 04-24-2012, 02:43 PM
  3. Taking screenshot with java applet using java robot class not working
    By sagngh8 in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 07-06-2011, 09:53 AM
  4. Java Problem! Java games freezing!!
    By L33t Walrus in forum Apple Desktops
    Replies: 1
    Last Post: 02-28-2010, 03:21 PM
  5. Help With Coding...
    By Doctor_Who in forum OS X - Development and Darwin
    Replies: 4
    Last Post: 06-19-2009, 02:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •