1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

learning Java, class is on Windows, I use Mac

Discussion in 'Mac Programming' started by letsdiscussit, Mar 1, 2008.

  1. macrumors newbie


    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
  2. macrumors 6502a


    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.
  3. macrumors newbie


    I am a little confused with the location of the Java SDK. Where is it exactly?
  4. macrumors 6502a


    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:

  5. macrumors 65816

    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.
  6. macrumors G4


    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.
  7. macrumors newbie

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


    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:

    Following the path you provided doesn't help me. What is the exact name of the program? TX
  9. macrumors 6502a

    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)


    (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).
  10. macrumors newbie

  11. macrumors G4


    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.
  12. macrumors newbie


    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);
    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)
    for(int i=0;i<b.length;i++)

    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.
  13. macrumors newbie

    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
  14. macrumors newbie


    How I am going to use Terminal to compile?
  15. Moderator


    Staff Member

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

    Let me bring your attention to an earlier post in this thread:
  16. macrumors newbie

    I recommend NetBeans. It's a great, colorful, and very full-featured (while still having a small learning curve) IDE.
  17. macrumors member

    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.
  18. macrumors newbie


    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.
  19. macrumors G4


    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.
  20. macrumors newbie

    Id recommend NetBeans because its cross platform
  21. macrumors G4


    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.
  22. Moderator


    Staff Member

    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.
  23. macrumors 6502

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

Share This Page