How to compile java programs using Windows Command line...

Hi friends I am absolute Newbie in Java.....So far I was compiling and running my Java Programs using Netbeans.....I read in some book that it can be done through Windows Command line also....I did following things......

1.] Wrote my simple program to display "Hello"

Progam:

class Test

{

public static void main(String args[])

{

System.out.println(" Hello !");

}

}

2.] Saved it using name Test.java

3.] Went to the directory in which I stored the file using command : cd

4.] I could see the file using dir command.

5.] Then I did: javac Test.java

But it threw an error:

'javac' is not recognized as an internal or external command,

operable program or batch file.

6.] My question is whats the problem, has it something to do with Windows Vista which I am using it or is that I don't have appropriate Java software installed.

7.] However this same program is giving desired results on Netbeans.

[1013 byte] By [Parag_Kalraa] at [2007-11-27 8:54:21]
# 1
Do you have java installed? http://java.sun.com/products/archive/
DenisKa at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 2
I don't know much about these archives........but I guess it has Java installed...simply bcoz in Vista Control pannel there is an icon of Java...also I guess netbeans itself installs Java by default....
Parag_Kalraa at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 3
I suggest getting JRE/JDE 1.5.
DenisKa at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 4
@DenisKI just checked C:\ Program Files\Java\It contains two directories:1.] jdk1.6.02.] jre1.6.0So I guess I have got an updated version of what u are asking me to download....So I guess that should not be the problem....
Parag_Kalraa at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 5
You need to set your Path variable. http://java.sun.com/docs/books/tutorial/getStarted/problems/index.html
DarumAa at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 6
Yeah it's your path variables. Follow what Darum posted.
DenisKa at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 7
HiI had the same problem as you. I had to put in a line in Autoexec.bat.
javaguy387a at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 8
> Hi> I had the same problem as you. I had to put in a line> in Autoexec.bat.NO! No you didn't. You should not have to modify Autoexec.bat. Just read the link provided above.
floundera at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 9

Hi,

Save the text below in notepad with a .reg extention and then run it. Great simple utilitiy for allowing you to right click any folder and run the command prompt. Makes life a little easier.

Cheers

bunniesgirl

[HKEY_CLASSES_ROOT\Directory\shell\Command]

@="Command &Prompt"

[HKEY_CLASSES_ROOT\Directory\shell\Command\command]

@="cmd.exe"

Message was edited by:

bunniesgirl

Message was edited by:

bunniesgirl

bunniesgirla at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 10

The same thing happened to me, so i followed the link you guys posted above and i used this C:\Documents and Settings\acer>cd Desktop

C:\Documents and Settings\acer\Desktop>cd New Folder

C:\Documents and Settings\acer\Desktop\New Folder>C:\Program Files\Java\jdk1.6.0

_01\bin\javac DotCom.java

in the command prompt and it gave me this error

'C:\Program' is not recognized as an internal or external command,

operable program or batch file.

How can i fix this?

The_Undeada at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...
# 11
It is because of the space. It interprets that as C:\Progam is the command and the rest is the argument to that command. Simply place quotes " " around Program Files.
floundera at 2007-7-12 21:13:36 > top of Java-index,Java Essentials,New To Java...