how to run java using the command prompt?

Short Run Printing

hey i need help. big noob at programming. ok so what happened is that i made a java program. I compiled using javac on the command prompt but after i compiled it i didn’t kno hjow to run it. Please help because i would love to program.
P.S. i made the program with notepad++
p.s.s i also made sure it was written correctly, here is a copy:
/*
Convert.class a short table of common
conversion factors.
*/

class Convertjava {

/*
* Note that the main method must be defined as
*public static void main (String []) to be called from
*the java interpreter
*/

public static void main (String args[]) {

double mi_to_km = 1.609;
double gals_to_l = 3.79;
double kg_to_lbs = 2.2;

System.out.print ("1 Mile equals\t");
System.out.print (mi_to_km);
System.out.println ("\tLiters\n");

System.out.print ("1 Gallon equals\t");
System.out.print (gals_to_l);
System.out.print ("\tLiters\n");

System.out.print ("1 Kilogram equals\t");
System.out.print (kg_to_lbs);
System.out.println ("\tPounds");
}
}

i also couldnt get this one to run:
/*
Hellow world
*/

public class helloworld {

public static void main(String[] args) {

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

}

}
also, the first progam is from a book called java 1.2 how-to
the second one is from you tube


One Response to “how to run java using the command prompt?”

  1. Fudge — December 6, 2009 @ 1:06 am

    hey,
    did the program get compiled ? if so, then just compile it again and run it as this :
    assume u compile at c:\java and ur file name is x.java

    to compile :
    javac x.java

    to run :
    java x

    don’t type the .class

    the book u r using i think has a full section at the beginning on how to compile /run programs , called (" Before you begin) : ; plz check it and any problem just ask here

    Good luck

Leave a Reply

Powered by Yahoo! Answers
Powered by WP VideoTube