Results 1 to 3 of 3
- 05-07-2011, 05:30 AM #1
Member
- Join Date
- May 2011
- Posts
- 9
- Rep Power
- 0
Mac Java writers: see if you can improve this instruction set
Hello,
This thread is designed for experienced Java coders who use Mac computers as their principal Java coding machinery. Anyone else, please ignore this thread.
After some considerable fumbling in the dark and battling the unknown, I have devised an instruction "cookbook" recipe on how to write, compile, and run a basic Java program on the Mac using only TextEdit and Terminal. If you can improve on this instruction set, please point out how. The way I wrote this instruction set works when the .java file is saved in the computer's user name directory. If the .java file is saved in some other directory that the coder chooses, I don't believe this instruction set will work, and I do not know how to instruct the Terminal program to go out and find the file. But this instruction set *does* work if you are sure to save the .java file in the user name folder. I tested it with a simple println program and a JOptionPane swing program, and they both compiled and ran according to expectations. So I am concluding (unless shown otherwise) that the procedure I devised below is a sound one for simple Java program creations.
Here are the instructions I came up with on my own. I welcome any specific improvements (i.e. an exact procedural step to add or subtract in what I typed below). For the sake of this instruction set, we will assume your computer user account name is JoeSmith, and you wish to create a Java program called Basketball
1) Open TextEdit on your Mac computer (running OS 10.6.x with Java 1.6 SE installed). TextEdit is located on your Mac computer at Go>>Applications>>TextEdit
2) Go into Preferences within TextEdit. Make sure it is set to plain text. This is important.
3) Type your Java program into the blank TextEdit file that you just opened in step 1. When you are coding, *make sure* you name the class Basketball, like this:
public class Basketball {
4) Go to File>>Save As. Name your file this exactly: Basketball.java
5) Save this file in your JoeSmith directory (the main account directory for your computer that the Mac will always want to seem to show you when you are looking for files and stuff like that).
6) Close the TextEdit Basketball.java file you just saved.
7) Launch the Mac program called Terminal by going to Go>>Applications>>Utilities>>Terminal
8) Type this exact thing into the command prompt in Terminal: javac Basketball.java
9) Look carefully in your JoeSmith file listings. You should see a file called Basketball.class magically appear. That's a good sign. You should also see your original Basketball.java file that you typed and saved earlier.
10) Now type this exact thing into the command prompt in Terminal: java Basketball
11) Your program should run as expected.Last edited by java beginner; 05-07-2011 at 05:56 AM.
- 05-07-2011, 05:49 AM #2
You use "cd" to Change Directory if the file is saved somewhere else ;)
Also this instruction set is what you are supposed to do and could easily be found with a simple Google search, unless Google is broken in your part of the world. :DJava Code:cd folderName
Nonetheless, this is useful to those also groping in the dark trying to figure things out by themselves.
- 05-07-2011, 06:02 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I'm a windows user and this seems like for most operating systems it's one of the challenges.
You should look into how to move around in the computer using cd and the other terminal Mac commands. You can probably find them at a Mac site if you are nervous about using random links. It will definitely be helpful to know how to navigate.
Similar Threads
-
Critique Java Game: Help Me Improve
By gretty in forum New To JavaReplies: 1Last Post: 07-15-2010, 04:30 AM -
Help with instruction
By diegoyj in forum New To JavaReplies: 1Last Post: 01-27-2010, 10:09 PM -
trying to improve code to avoid java.lang.OutOfMemory error
By bdyarem in forum New To JavaReplies: 16Last Post: 08-05-2008, 11:34 AM -
How can I improve the execution time of a Java Project
By Ndt in forum Advanced JavaReplies: 25Last Post: 06-28-2008, 05:08 PM -
how to improve java performance
By sunjavaboy in forum Advanced JavaReplies: 6Last Post: 06-15-2008, 05:58 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks