Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JuliaG

macrumors newbie
Original poster
Nov 25, 2008
3
0
My sister has to take a class on Java at community college to fulfill her requirements to move on to four year. Even though she does not have to take the class anymore I made her keep the book she bought because I am interested in learning. But I am way confused.
I need an editor. I know mac comes with text edit so could that work as my editor for java. Also it says macs are known to come with Java already installed. I have a mac book pro. In the book it says to open terminal and enter to see if you have java installed.
javac
I did that but it did not recognize it so that means it does not come with java on my computer. Here is what it said
Last login: Tue Nov 25 11:17:47 on ttys000
apples-macbook-pro-2:~ juliagrohman$ javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system

apples-macbook-pro-2:~ juliagrohman$
So does that mean I Have dont have java included. If not how do I download java. Because it says the place to download java java.sun.com does not support mac operating systems. Please help me as I am very confused and want to start learning java. Please help me.
 

plinden

macrumors 601
Apr 8, 2004
4,029
142
No, the response you got does mean javac is installed. If it wasn't you would get:
Code:
-bash: javac: command not found

By the way, I enclosed that in CODE tags which makes it easier to read. You should do the same.

Just typing "javac" isn't valid - you need to provide a source file for javac to compile, something like this:

Code:
public class HelloYellowJello {
    public static final void main(String[] args) {
        System.out.println("Hello yellow jello");
    }
}

saved to "HelloYellowJello.java" - the file name MUST match the class name in the file.

Type after saving:
Code:
javac HelloYellowJello.java
java HelloYellowJello

Edit: depending on your Terminal setup, you might need to type
Code:
java -cp . HelloYellowJello
to get it to run if you get "java.lang.NoClassDefFoundError: HelloYellowJello"
 

ChrisA

macrumors G5
Jan 5, 2006
12,919
2,173
Redondo Beach, California
....
I did that but it did not recognize it so that means it does not come with java on my computer. Here is what it said
Last login: Tue Nov 25 11:17:47 on ttys000
apples-macbook-pro-2:~ juliagrohman$ javac
Usage: javac <options> <source files>
where possible options include:...

Looks like it worked. You typed "javac" so it ran the javac program. That program looked at the command line for the name of a java program, did not find one, nor did it find anything else so it printed a list of valid things it would accept.
 

JuliaG

macrumors newbie
Original poster
Nov 25, 2008
3
0
Thanks everyone. This is good news yes. I have one more question. Will textedit work for my java editor.
 

HOiYA

macrumors member
Feb 13, 2008
36
0
I would recommend that you use something other than textpad as your editor. You can download XCode from Apple. I hear it has a decent java editor. Personally I use eclipse. I have used it extensively for work for the past 8 years. And since it is open source, you will find almost any plugin you will ever need.
 

ChrisBrightwell

macrumors 68020
Apr 5, 2004
2,294
0
Huntsville, AL
For a beginning programmer, I recommend a basic text editor (I use TextMate, which I can't recommend highly enough) and command-line build tools.

Using an IDE, such as Xcode or Eclipse, abstracts the build process away from the student and hides it all behind this weird fog of binary voodoo. Getting your hands dirty, with javac and gcc and anything else, is really the best way to learn.
 

Amuraivel

macrumors member
Jan 31, 2006
91
0
Using an IDE, such as Xcode or Eclipse, abstracts the build process away from the student and hides it all behind this weird fog of binary voodoo. Getting your hands dirty, with javac and gcc and anything else, is really the best way to learn.

I disagree, there is nothing more frustrating than trying to do arcane commands at the command line when you are trying to learn how to program. One layer of complexity.

That said some IDE's have a steep learning curve themselves.

Xcode can just be used as a good text editor.

For Java programming with a decent set of training wheels I like IntelliJ. It parses the code making things easier.
 

daflake

macrumors 6502a
Apr 8, 2008
920
4,329
LOL, the IDE debate has been going on for years. I started with a textpad but quickly moved to Netbeans for my IDE. It is all I use now. You have to be willing to dig into them though....
 

Amuraivel

macrumors member
Jan 31, 2006
91
0
While we are on the topic.

Does anyone know of a parser/language spec set for Xcode three that works for java?

Like if type: Math.

That I get all the choices like, Math.round(), Math.sqrt(), etc.
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
While we are on the topic.

Does anyone know of a parser/language spec set for Xcode three that works for java?

Like if type: Math.

That I get all the choices like, Math.round(), Math.sqrt(), etc.

XCode does do that, you just need to hit the ESC* key to bring up code completion list.

*This may not be the default key since I may have changed it on my machine, check your prefs for the "Completion List" command
 

notjustjay

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
I disagree, there is nothing more frustrating than trying to do arcane commands at the command line when you are trying to learn how to program. One layer of complexity.

That said some IDE's have a steep learning curve themselves.

Exactly.

A beginning programmer really needs to learn the relationship between the characters they type and the way the compiler reacts to it and the output it generates. IDE's abstract that all away, showing you class trees and root nodes and autocompleting, you need to set up project files and go through the build manager and blah blah blah. Which is all wonderful once you understand what's going on (I love Eclipse), but too much all at once for the beginner.

Take a plain text editor, type in 4 lines of "Hello World" code, type two commands into the shell and suddenly everything starts to make sense at the most basic level. You can ramp up very quickly from there.

Start someone too quickly with a GUI and not only will they have to fight the learning curve, but you'll get questions like the one in the first post, where the OP didn't see the relationship between the command line and the output it generated (no offense intended to the OP, of course). Teach a kid to rely on a calculator too soon and their basic math skills will suffer.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I will breifly restate what I say every time this comes up:
Learn with the basic tools (a text editor, java, javac, jar in this case). When you are totally comfortable with these, and find that your projects get very large, then you can learn ant and be even more proficient in standard tools, or switch to an IDE.

Jumping into an IDE immediately robs you of valuable experience and knowledge.

If/when you switch to an IDE, make sure it is crossplatform so you are not locked in to one environment.

In summary, focus first on the language syntax and basic tools, not on learning an IDE.

-Lee
 

ChrisBrightwell

macrumors 68020
Apr 5, 2004
2,294
0
Huntsville, AL
I disagree, there is nothing more frustrating than trying to do arcane commands at the command line when you are trying to learn how to program. One layer of complexity.

... Are you serious? Adding the IDE in the mix introduces a layer of complexity. Not only do you have to install and configure the IDE, but you still have to be able to read and understand the compiler when it complains.
 

mkelly11

macrumors newbie
Dec 1, 2008
7
0
Take a look at using Java in xcode. You've got your source files sorted out neatly, your code highlighted neatly, and the tools you need all in one place. When you build it, the compiler doesn't just output some hard-to-deciper text; instead, it cleanly and concisely lists all of the errors and warnings, and even lets you jump to their location with a single click. But with a command prompt, you've got none of this functionality. While I guess you could say it's good to learn how to use the command line to compile, it's certainly not the highest priority thing when you're learning a new language. It really just throws out another unnecessary hurdle. I think it's best to start off in a comfortable spot, and then learn about what's going on underneath the hood of the IDE.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.