Jesper Young wrote:
R Arthur wrote:I guess I just haven't grasped how one compiles .java files using javac......what program is used to compile?
The program that you use to compile Java source files to Java class files is javac, the Java compiler. It doesn't have a graphical user interface, it's a program that you use on the command line of the terminal window.
The page About the Java Technology from Sun's tutorials explains it in detail, with pictures:
Janeice DelVecchio wrote:Okay.... here's another way to say this. I'm used to PC, but I think Macs are pretty much the same when it comes to this.....
The Java Virtual Machine is what most people have on their computers. It's used, most notably, to run Java based applications as well as view Java content on web pages.
The Java Developer Kit (JDK) is a bunch of stuff used by developers (like us) to compile programs. The programs are written in a text editor (if you're using the HeadFirst book I recommend NotePad++), or you can use a development environment like Eclipse.
"javac" is the compiler you need to get the files you write in your text editor to turn into useful Java class files. In windows, there's a way to add the file to the known paths of the operating system. I think that video I linked to might have information on that for Macs.
So you write a file, say "HelloWorld.java". How do you compile it?
Type:
... at the command prompt while you're in the folder that has the file in it. If you're lucky and there are no errors , you get a class file. So now you have 2 files with different extentions (one java that you wrote, the other class... the compiled version). The JVM runs the class files. If you set your system properties correctly, you should then be able to type
And your application will run.
Hello World!! :-)
Is this getting clearer? I remember it took me about a week to understand this whole thing when I started....
-Janeice
Bear Bibeault wrote:Once you are at the command line, you can just follow any tutorial on writing Java programs. There's nothing Mac-specific you need to worry about.
Essentially:
Write Java program in .java files using a text editor Compile .java files using javac; creates .class files Run program using java command
The devil is in the details. So pay attention to what the book is telling you.
Bear Bibeault wrote:Bring up a Terminal window, and enter javac at the command line.
If you get "command not found", the JDK is not installed.
If you get a usage message, you are good to go.
Campbell Ritchie wrote:Welcome to the Ranch
People will be keener to answer if you tell them what the question is about in the thread title.