Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

letsdiscussit

macrumors newbie
Original poster
Jun 26, 2007
27
0
I just started learning Java in the college. They want me to program something simple, that I have at the end xxx.java xxx.class xxx.html. So all these nerds in the class use Windows and I have a Mac and I read that Java SDK is included in OSX 10.4. My question, is Java on Mac different or platform independent? Where is the Java SDK on OSX? I don't want to partition my Mac and install Windows and hope on a solution to develop Java on a Mac.

please look down to my last thread
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
Java is ostensibly platform independent. When you write a Java program, it's compiled to bytecode that's executed on a Java Virtual Machine. So what you write on your Mac should, unless you provide OS X specific hooks, run on Windows without a rewrite or recompile.

You'll find your Java installation under /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks.
 

letsdiscussit

macrumors newbie
Original poster
Jun 26, 2007
27
0
I am a little confused with the location of the Java SDK. Where is it exactly?
 

kuwisdelu

macrumors 65816
Jan 13, 2008
1,323
2
For Java development, Eclipse is probably more appropriate than XCode, which--while it can do Java, of course--is a rather powerful but confusing IDE for beginners. You can find Eclipse for Mac, but I believe you will need to install the Developer Tools anyway to get the Java SDK. I'm not sure. Once you get one or the other figured out, though, you shouldn't run into any problems with Java compatibility between Mac and Windows.
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
You need to install Xcode to get the developer tools.

Personally as a beginner I'd use a text editor (the one in Xcode is fine) and then compile the source on the command line with javac. However if the class is using a specific IDE you should use the same one, there'll almost certainly be a Mac version.
 

letsdiscussit

macrumors newbie
Original poster
Jun 26, 2007
27
0
I successfully installed Java for Mac OS X 10.4, Release 6 but don't know where to look to find it.

Under Application I find this:
Java Plug-in Control Panel
Java Preferences
Java Web Start

I also have plenty of Java Folder:
JavaBeans
JavaScript
JavaInterpreter

Following the path you provided doesn't help me. What is the exact name of the program? TX
 
You should be able to open /Applications/Utilities/Terminal.app and enter:

java -version
and, for completeness
javac -version


This will confirm you have the java installed and that you can use the command line tool set.

You should find out what the recommended tools are for your class (e.g. Eclipse, NetBeans). Without question, it is best to use something as close to everyone else in the class. As mentioned above, there will likely be a Mac version (all major Java IDEs have a Mac version). If you can post back this info, someone will be able to help you through a basic project set up.

A simple example:
Create a plain text file (in any editor) with the contents:
Code:
class HelloWorld {
        public static void main(String [] args) {
                System.out.println("Hello World");
        }
}
and save it as ${HOME}/HelloWorld.java

Open the terminal and type
javac HelloWorld.java
Then run the resulting HelloWorld.class file with
java HelloWorld

(although I would advise creating a "projects" directory and a separate directory for each of your assignments)

HTH

(It also sounds like they want you to create an Applet rather than Application, as they want an html file, but more of that later).
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
If this is your first programming class then i would suggest using eclipse as your compiler

No you use the IDE (if any) that the class is using.

Frankly everyone in this thread is being very confusing, hell I'm a little confused and I write and release software.

Here are the instructions from the beginning.

1. Download Xcode from Apple.com you get it from here, but you will need a free Apple account to install it. You may also find Xcode on your Mac OS X DVD, under Optional Installs or something, but the version on Apple.com will be newer.

As you aren't on Leopard (10.5) you want Xcode 2.5

2. Install the default options. This will install the Java Development Kit so you'll be able to make Java software, as well as all the other development stuff which may be useful for future courses.

3. If the class is using an IDE such as Eclipse or Netbeans or Intellij then let us know, as in that case you should install it.

However if you are using a text editor and javac on the command line, you should stay away from IDE's as they are generally pretty complicated. However the Mac command line is Unix and is slightly different from the Windows one. This PDF looks OK, only the beginning few pages are relevant though.

Note an IDE is a piece of software that helps you write code, though these can be a little more complex than needed for a first programming course.
 

letsdiscussit

macrumors newbie
Original poster
Jun 26, 2007
27
0
Thanks all of you for your help. First, my homework assignment to give you a better idea of what the prof. expects from me. I just typed it up, don't know if the spacing is important. He wants us to come up with any sorting methodology that gets compiled and shown on the internet explorer. xxx.java xxx.class xxx.html

Complete the following Java program.

//This program sorts an array's values into ascending order
import java.awt.Graphics;
import java.applet.Applet
{
int a[]={55,25,66,45,8,10,12,89,68,37};
public void paint(Graphics g)
{
print(g,"Data items in original order",a,25,25);
sort();
print(g,"Data items in ascending order"",a,25,55);
}

/* A sorting method to be completed.*/

public void print(Graphics g, String head, int b[], int x, int y)
{
g.drawString(head,x,y);
X+=15;
y+=15;
for(int i=0;i<b.length;i++)
{
g.drawString(String.valueOf(b[i}),x,y);
}
}
}

Here to my dilemma. I am a MIS student and they give me this class bc. of lack of faculty to offer other classes. I am the only student with no prior programming skills. Anyway, installed Xcode and found it too complicated. I started a new project but didn't know what to do next. The Terminal is unfamiliar to me but I understand the purpose of it. Yes, I know I suck in programming but hope to change this soon.
 

guardian85

macrumors newbie
Feb 29, 2008
7
0
Xcode being too complicated for someone just beginning in the coding world is why i suggested eclipse its a great little compiler. You could use the terminal to compile your programs. If you want to try eclipse download it from the link i posted earlier.

worst case you try it, dont like it, remove it
 

Mitthrawnuruodo

Moderator emeritus
Mar 10, 2004
14,424
1,065
Bergen, Norway
For beginners I strongly recommend using the combination of a simple text editor (like TextWrangler) and compile using the Terminal. That is the only way to learn Java from scratch.

If you feel you need an idea, go with BlueJ.

Then, in a year or so, when you master those to perfection, it's time to bring in Eclipse (or NetBeans or whatever).

How I am going to use Terminal to compile?
Let me bring your attention to an earlier post in this thread:
A simple example:
Create a plain text file (in any editor) with the contents:
Code:
class HelloWorld {
        public static void main(String [] args) {
                System.out.println("Hello World");
        }
}
and save it as ${HOME}/HelloWorld.java

Open the terminal and type
javac HelloWorld.java
Then run the resulting HelloWorld.class file with
java HelloWorld
 

jbruce2112

macrumors newbie
Oct 2, 2006
26
0
I recommend NetBeans. It's a great, colorful, and very full-featured (while still having a small learning curve) IDE.
 

JEB229

macrumors member
Feb 21, 2008
48
0
I use netbeans for my java programming in my CS classes and everything compiles fine on both my mac laptop and the windows machines in class.
 

letsdiscussit

macrumors newbie
Original poster
Jun 26, 2007
27
0
After installing all kinds of programs, a friend of mine showed mercy and gave me a 2 hour tutorial of netBeans. I did my home work. It's not east but got used to a few standard functions to write and run the code.
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
After installing all kinds of programs, a friend of mine showed mercy and gave me a 2 hour tutorial of netBeans. I did my home work. It's not east but got used to a few standard functions to write and run the code.

What software is the professor teaching you to use on Windows? Though if you are using Netbeans now its probably worth sticking with it. Also what version of Internet Explorer are you targeting as you'll need to test your code on that.
 

shaggymac

macrumors newbie
Mar 6, 2008
17
0
What software is the professor teaching you to use on Windows? Though if you are using Netbeans now its probably worth sticking with it. Also what version of Internet Explorer are you targeting as you'll need to test your code on that.

Id recommend NetBeans because its cross platform
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
After installing all kinds of programs, a friend of mine showed mercy and gave me a 2 hour tutorial of netBeans. I did my home work. It's not east but got used to a few standard functions to write and run the code.
So, you didn't even try the simple text-editor / command-line approach that AlmostThere provided?

Whenever learning a new programming language, I always suggest starting with the basics (i.e. no IDE). That way you are at least comfortable with the "lowest common denominator" that will be available to you wherever you code (although there may be slight platform differences, such as navigating directories in Unix vs. Windows). Once you are comfortable with the basics, then you can incorporate an IDE into your programming approach.

It's like learning to navigate by starting with a GPS when a map and compass should probably be what you start with.
 

Zortrium

macrumors 6502
Jun 23, 2003
461
0
Back when I learned Java I started with BlueJ (a beginner-friendly IDE designed for teaching) for a couple months, then did everything on the terminal for a few months before moving on to a full blown IDE (Eclipse). I think it's a good approach - I certainly wouldn't have wanted to dive right into Eclipse when I was just learning (I still probably don't know 90% of the stuff Eclipse does...).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.