Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Using Terminal to program and test java.

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)

Posted on Oct 1, 2007 6:30 PM

Reply
9 replies

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

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.

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

Oct 3, 2007 9:00 PM in response to etresoft

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

Oct 4, 2007 3:28 PM in response to etresoft

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.

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.

Oct 4, 2007 8:01 PM in response to etresoft

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.

Using Terminal to program and test java.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.