PDA

View Full Version : learning Java, class is on Windows, I use Mac




letsdiscussit
Mar 1, 2008, 11:40 AM
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
Mar 1, 2008, 11:55 AM
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
Mar 1, 2008, 12:46 PM
I am a little confused with the location of the Java SDK. Where is it exactly?

yeroen
Mar 1, 2008, 01:32 PM
Have you installed Xcode yet? You need to install Xcode to have the /Developer directory tree.

How far have you gotten in trying to find it?

If you still can't find it, you can download it from here:

http://developer.apple.com/java/download/

kuwisdelu
Mar 1, 2008, 01:47 PM
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
Mar 1, 2008, 02:00 PM
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.

rappr
Mar 1, 2008, 02:33 PM
I am a little confused with the location of the Java SDK. Where is it exactly?

The symbolic links in /Library/Java/Home for command-line tools javac and java point to /usr/bin, I'd look there as well.

letsdiscussit
Mar 1, 2008, 03:53 PM
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

AlmostThere
Mar 1, 2008, 04:09 PM
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:

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).

guardian85
Mar 2, 2008, 01:29 AM
If this is your first programming class then i would suggest using eclipse as your compiler

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/europa/winter/eclipse-jee-europa-winter-macosx-carbon.tar.gz


the link above is for eclipse for the mac OS

Its pretty straight forward for a compiler and is easier to use than xcode or a text editor and compile via command line.

Eraserhead
Mar 2, 2008, 04:46 AM
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 (http://developer.apple.com/tools/download/), 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 (homepage.mac.com/rgriff/files/TerminalBasics.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
Mar 3, 2008, 01:27 PM
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
Mar 3, 2008, 03:06 PM
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

letsdiscussit
Mar 3, 2008, 03:12 PM
How I am going to use Terminal to compile?

Mitthrawnuruodo
Mar 3, 2008, 03:14 PM
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 (http://www.bluej.org/).

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:

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
Mar 3, 2008, 08:28 PM
I recommend NetBeans. It's a great, colorful, and very full-featured (while still having a small learning curve) IDE.

JEB229
Mar 3, 2008, 11:05 PM
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
Mar 4, 2008, 01:23 PM
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
Mar 4, 2008, 01:40 PM
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
Mar 6, 2008, 10:56 AM
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

Eraserhead
Mar 6, 2008, 11:10 AM
Id recommend NetBeans because its cross platform

All the Java IDE's are cross platform except Xcode, so it isn't an issue. It also isn't an issue if you are only using Xcode as a text editor.

dejo
Mar 6, 2008, 11:22 AM
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
Mar 6, 2008, 01:16 PM
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...).