我如何从我的Windows计算机的命令行运行此java程序?

时间:2011-11-11 23:03:22

标签: java

它在我的桌面上,如果你能一步一步告诉我如何运行这个程序。我知道javac编译程序。

public class SimpleProgram {
    public static void main(String[] args){
        System.out.println("A proverb");
        String Proverb  = "Practice makes perfect!";
        System.out.println("Proverb");
        int CharacterCount = Proverb.length();
        Syetem.out.println("The Proverb has "+CharacterCount + "Characters");
    }
}

5 个答案:

答案 0 :(得分:1)

在命令提示符下,您可以使用Java命令运行您的类,并按照以下确切语法进行操作。

C:> java SimpleProgram

答案 1 :(得分:1)

答案 2 :(得分:1)

您发布的程序将编译。这是以下版本:

 
public class SimpleProgram {

    public static void main( String[] args ) {

      System.out.println( "A proverb:" );
      String proverb  = "Practice makes perfect!";
      System.out.println( "Proverb" );
      int characterCount = proverb.length();
      System.out.println( "The Proverb has " + characterCount + " Characters" );
    }
}

您可以编译它并运行:

 
$ javac SimpleProgram.java 
$ java SimpleProgram
A proverb:
Proverb
The Proverb has 23 Characters

答案 3 :(得分:1)

编译do java SimpleProgram

如果你不想这样做来回Textpad

答案 4 :(得分:1)