Newbie Compiling
Okay, I'm a student and am brand new to Java and programming in general. I'm I have JDK 6 installed and ready to go as well as notepad up and running. I made the "Hello World!" file, but am having trouble compiling it. When I open the command prompt in XP, I am unable to get into the source directory that would allow me to start compiling. This is the link <http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html> I am referring to, and am confused at the point where it says "Compile the Source File into a .class File". So what I want to know is what I need to enter to get into that directory and start compiling. Any help that could allow me to start programming would be greatly helpful.
[725 byte] By [
dohuya] at [2007-11-27 5:18:58]

Use the "cd" command to change directories.
Is that your question?
You might also want to check your PATH environment variable.
This seems to be a common newbie problem.
Type:
echo %PATH%
on the command line; it should respond with a list of directories separated by semicolons. One of those directories should include the Java 1.6 JDK.
sometimes i am happy that the first real OS i used was dos 4.0
Not quite. My question is this: when I type "dir" into the command line, why am I not able to see the helloworldapp file? The file is on my C: so I am wondering why it can't find it.
dohuya at 2007-7-12 10:42:13 >

Did you somehow make the file hidden?If the file is located EXACTLY at C:/HelloWorldApp.java, navigating to C:/ and typing dir from the command line WILL show this file.
I wouldn't suggest you jump to an IDE, but the text editor TextPad:
http://www.textpad.com/
is free to download, and has menu items for compiling and running Java.
You should still learn your way around a command prompt, but typing Ctrl+1 Ctrl+2 (compile, execute)
is darn handy.
If you mean that it's in the root folder in your C: drive, then just type cd \into your command prompt, then javac HelloWorldApp.javato compile it. If the 'javac' command doesn't work, we'll have to dink with your %path% variable. Let me know how it goes.
So here's what I did:
1. I had the file deep within one of my other folders and moved it directly to the C drive
2. Typed CD \
into the command prompt and up came C:\
3. Typed dir
and came up with "Volume in drive C has no label" "Volume Serial Number is F49C-142B" with the Directory of C:\ to follow
4: Saw the HelloWorldApp.java file there and typed javac HelloWorldApp.java
. Resulted with 'javac' is not recognized as an internal or external command, operable program or batch file
So does this have something to do with my installation of JDK? Also, is reading this tutorial a good way of trying to teach yourself java, or do I need to pick up a book?
dohuya at 2007-7-12 10:42:14 >

You need to set your path variable.I just explained how to do this here: http://forum.java.sun.com/thread.jspa?threadID=5175932&tstart=0It's in the last 10 or so posts.
Whoa, thanks a lot for your help. It works. Now, one question is do I need to change the classpath as well like flounder said in that thread? Also, how would I change the directory to a different folder? Do I just type cd \folder\folder\java?
dohuya at 2007-7-12 10:42:14 >

> Whoa, thanks a lot for your help. It works. Now, one
> question is do I need to change the classpath as well
> like flounder said in that thread? Also, how would I
> change the directory to a different folder? Do I just
> type cd \folder\folder\java
?
Personally, I don't like setting the classpath as an environment variable. Whenever it needs to be set, I will pass it as a command line parameter as such:
java -cp path_to_libraries myClassFile
javac -classpath path_to_libraries myJavaFilesToBeCompiled
As for changing directories, yes, CD works. CD actually means CHANGE DIRECTORY.
Here are a few little tips for moving around on the command prompt (in windows):
CD .. - takes you back a directory
CD \ - takes you to the root directory (C:\)
MD - make directory. (MD myJavaFolder, etc.)
RMDIR - remove directory
DIR - list all files and directories in the current directory
DIR/W - list all files and directories in the current directory in "wide" format
Also, you don't always need to specify the absolute path when you CD.
For example, if you type
DIR/W *. and press enter, you'll get a list of all directories (directories are listed with brackets ([]) around them, i.e. [windows]). To move to any one of those directories, type CD directory_name, etc. But, I'm sure you can find a thousand tutorials online that are far more instructive this one.
