New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

Coding C++ and Java


Post Reply New Thread Subscribe

 
Thread Tools
Ciwan

 
Ciwan's Avatar
 
Member Since: Oct 30, 2009
Location: The Milky Way
Posts: 137
Ciwan is on a distinguished road
Mac Specs: iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard

Ciwan is offline
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)
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,882
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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
QUOTE Thanks
Ciwan

 
Ciwan's Avatar
 
Member Since: Oct 30, 2009
Location: The Milky Way
Posts: 137
Ciwan is on a distinguished road
Mac Specs: iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard

Ciwan is offline
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)
QUOTE Thanks
Ciwan

 
Ciwan's Avatar
 
Member Since: Oct 30, 2009
Location: The Milky Way
Posts: 137
Ciwan is on a distinguished road
Mac Specs: iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard

Ciwan is offline
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)
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,882
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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
QUOTE Thanks
Ciwan

 
Ciwan's Avatar
 
Member Since: Oct 30, 2009
Location: The Milky Way
Posts: 137
Ciwan is on a distinguished road
Mac Specs: iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard

Ciwan is offline
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)
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,882
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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
QUOTE Thanks
Ciwan

 
Ciwan's Avatar
 
Member Since: Oct 30, 2009
Location: The Milky Way
Posts: 137
Ciwan is on a distinguished road
Mac Specs: iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard

Ciwan is offline
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)
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,882
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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
QUOTE Thanks
Ciwan

 
Ciwan's Avatar
 
Member Since: Oct 30, 2009
Location: The Milky Way
Posts: 137
Ciwan is on a distinguished road
Mac Specs: iMac Core i5 2.66GHz - RAM 4GB - OS X Snow Leopard

Ciwan is offline
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)
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,882
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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
QUOTE Thanks
Zoolook

 
Zoolook's Avatar
 
Member Since: Sep 24, 2006
Location: Brooklyn, New York
Posts: 2,751
Zoolook has much to be proud ofZoolook has much to be proud ofZoolook has much to be proud ofZoolook has much to be proud ofZoolook has much to be proud ofZoolook has much to be proud ofZoolook has much to be proud ofZoolook has much to be proud ofZoolook has much to be proud of
Mac Specs: 15" MacBook Pro, i7 2.66Ghz, 8GB RAM, 512GB SSD; iPad 3, iPhone 5

Zoolook is offline
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

QUOTE Thanks

Post Reply New Thread Subscribe


« Screen resolution - too small???? | upgrading powerbook operating system »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Snow Leopard > Firefox 3.6 > Java not working... slater OS X - Apps and Games 6 04-03-2011 10:03 AM
How to download older version of Java for mac aarthi Switcher Hangout 3 05-11-2010 05:32 PM
Problem with Java Se6 on 10.5.8 joskibob OS X - Operating System 2 12-24-2009 03:47 PM
weird java problem rerks OS X - Apps and Games 0 01-28-2007 05:59 AM
Java From Terminal jdgti OS X - Development and Darwin 10 03-26-2005 07:16 PM

All times are GMT -4. The time now is 12:38 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?