run using cmd

when i run a .java program using cmd, it seems I can only run it if there is a .class with the file.

How do i create that .class file which corresponds with the .java program, without using jcreator which automatically creates it for me?

Also whats the difference between typing:

java *.java

javac *.java

Thanks

[348 byte] By [darksssa] at [2007-10-3 9:22:43]
# 1
javac will create the .class files if the program compiles. You then use java to execute them. For example:javac HelloWorld.javajava HelloWorldYou do not include the .java when executing.
CaptainMorgan08a at 2007-7-15 4:36:25 > top of Java-index,Developer Tools,Java Compiler...
# 2

I tried that out, but it said that:

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

operable program or batch file.

I typed in javac Dice.java

for a simple java program:

// comments

import java.util.Scanner;

public class Dice

{

public static void main (String[] args)

{

Scanner input = new Scanner (System.in);

// Varibles

int sides, dienum;

// comment

System.out.println ("This program will allow you to type in any number"

+ " of sides you want on a die.");

System.out.println ("Then the die will roll and give you the results");

System.out.println ("So please input the number of sides ");

sides = input.nextInt();

//If and else statement, incase user types in 0 or less

if (sides <= 0)

System.out.println ("You can't roll a dice with that many sides.");

else

{

// Code to roll the die

dienum = (int)(Math.random() * sides + 1);

// Result

System.out.println ("Your number rolled is: " + dienum);

}

}

}

is there something wrong with my porgram?

or with my cmd or what i typed in?

Thanks

darksssa at 2007-7-15 4:36:25 > top of Java-index,Developer Tools,Java Compiler...
# 3
You need to set the PATH variable.PATH="C:\Program Files\Java\jdk1.5.0_09\bin\"Just change that to the location of your bin folder. It will recognize javac after you do that properly.
CaptainMorgan08a at 2007-7-15 4:36:25 > top of Java-index,Developer Tools,Java Compiler...