Skip navigation
This discussion is archived

Using Terminal to program and test java.

1434 Views 9 Replies Latest reply: Oct 4, 2007 8:33 PM by David Bixler RSS
David Bixler Calculating status...
Currently Being Moderated
Oct 1, 2007 6:30 PM
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)
    Currently Being Moderated
    Oct 2, 2007 6:21 AM (in response to David Bixler)
    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
    Mac Book, Mac OS X (10.4.8)
  • etresoft Level 7 Level 7 (23,905 points)
    Currently Being Moderated
    Oct 2, 2007 6:25 AM (in response to David Bixler)
    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.
    MacBook, Mac OS X (10.4.10), 1.83Ghz/2GB Ram/80 HD +iMac G4 800
  • Dale Ranta Level 4 Level 4 (1,660 points)
    Currently Being Moderated
    Oct 2, 2007 8:23 AM (in response to David Bixler)
    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
    G4 Dual 1.25
  • etresoft Level 7 Level 7 (23,905 points)
    Currently Being Moderated
    Oct 4, 2007 1:58 PM (in response to David Bixler)
    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.
    MacBook, Mac OS X (10.4.10), 1.83Ghz/2GB Ram/80 HD +iMac G4 800
  • etresoft Level 7 Level 7 (23,905 points)
    Currently Being Moderated
    Oct 4, 2007 5:59 PM (in response to David Bixler)
    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.
    MacBook, Mac OS X (10.4.10), 1.83Ghz/2GB Ram/80 HD +iMac G4 800

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.