9 Replies Latest reply: Oct 4, 2007 8:33 PM by David Bixler
David Bixler Level 1 Level 1 (45 points)
I bought a book on java and it says I should not use a JDK when first learning java.

Right or wrong I would like to know how to use terminal to program and compile simple scripts.

So my question is:

How do you go about setting up the computer to use terminal to write and compile a java program?

I know that’s pretty big question. I just need a link to some info on how to get started using terminal and java.

If I use a text editor how do I set up a path to it using javac?

Where can I find or link to this kind of info?

Macbook Pro, Mac OS X (10.4.10)
  • Bob Lang1 Level 5 Level 5 (4,080 points)
    See my notes here:
    http://www.cems.uwe.ac.uk/~lrlang/javasoundmusic/index.html#worksheets

    These worksheets will take you through the process of using Xcode to create Java programs.

    The comment on not using a JDK is nonsensical. You MUST use a JDK to create a Java program! It probably means to say that you should not use an IDE. If so, that's also nonsense.

    Bob
  • etresoft Level 7 Level 7 (25,950 points)
    David Bixler wrote:
    I bought a book on java and it says I should not use a JDK when first learning java.


    I think they mean IDE, considering that Java is the JDK. And I agree with that idea, not just for Java, but for any language.

    How do you go about setting up the computer to use terminal to write and compile a java program?


    There isn't anything to setup. Just run Terminal and type "vi hello.java" or "nano hello.java". To compile, type "javac hello.java".

    I know that’s pretty big question. I just need a link to some info on how to get started using terminal and java.


    That is not necessarily a big question, just fundamental. Try Google. It becomes second nature after a couple of decades so I don't really know where to tell you to look. People do tend to have a big list of links, hopefully they can contribute some.

    If I use a text editor how do I set up a path to it using javac?


    It should already be in your path.

    Where can I find or link to this kind of info?


    Try Google. People like it. You should find many pages similar to this.
  • Dale Ranta Level 4 Level 4 (1,660 points)
    Running java is easy -

    [dranta:~/tests] dir% javac testcpu.java
    [dranta:~/tests] dir% java testcpu


    will compile and run your simple programs.


    [dranta:~/tests] dir% which javac
    /usr/bin/javac
    [dranta:~/tests] dir% which java
    /usr/bin/java


    shows links to javac and java in /usr/bin


    [dranta:~/tests] dir% ls -l /usr/bin/javac
    lrwxr-xr-x 1 root wheel 78 Mar 5 2007 /usr/bin/javac -> /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/javac
  • David Bixler Level 1 Level 1 (45 points)
    Thanks for the info. It may take me a few days to get to it. I have to put my computer back together.

    I was messing around in terminal and was trying to change my short name in system preferences and lost a bunch of stuff like all my mail.

    Note to self: Don't do that again.

    I also found a good description and some basic unix commands in Tiger Missing Manual
  • etresoft Level 7 Level 7 (25,950 points)
    Before you do too much work, maybe create a new thread and explain what you did. It may be easy to fix. If you know what you're doing, you can change your short name pretty easily.
  • David Bixler Level 1 Level 1 (45 points)
    I thought it was going to be simple. Most things are simple if you know what your doing.

    All I did was highlight and change my name under my house icon in the users folder.

    When I logged out and then back in it put all my stuff in a different folder under users, wipped out my mail and a bunch of other stuff and my short name did not change. That was the bad part.

    Good Idea, I will start another thread.
  • etresoft Level 7 Level 7 (25,950 points)
    All your stuff is still there. Go into the /Users directory and rename the folder with your old name to be "old.broken". Then, rename the folder with your new name to be the same as your old name. Log out and log back in. With any luck, you will be back in business. Delete that "old.broken" folder when everything is working properly.
  • David Bixler Level 1 Level 1 (45 points)
    I think I'll put it back togeather the old fasion way, a few folders at a time.

    Like I said my old shortname( the original folder ) will not change. It just dumps all my files into a new folder with a new name .

    I stll have my little house there with my orginal name under it and in terminal my shortname is still long.

    I did how ever finally figure out how to navigate through the command line to a folder and then compile and run a java app. All is not lost yet.
  • David Bixler Level 1 Level 1 (45 points)
    I did have to use terminal to navigate to a folder that held my text files for the java program I was building.

    I dug out my Missing Manual for Tiger and used the chapter on terminal to figure out the directory thing.

    Easy if you know what your doing.

    Still got a long was to go but I'm now past start.