-2

Its on my desktop, if you could tell me step by step how i can run this program. I know javac compiles the program.

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");
    }
}
1

5 Answers 5

1

From the command prompt you can use Java command to run your class and follow it in the exact syntax as follows.

C:> java SimpleProgram

Sign up to request clarification or add additional context in comments.

Comments

1

Running a Java Program from Command Prompt

Comments

1

Your program will not compile, as you posted it. Here is the version that will:

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" );
    }
}

You can compile it and run as:

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

2 Comments

it wont run, it says $ javac SimpleProgram.java is not recognized as an external or internal command.
I just ran it in the example above. What you need to do is to install java, or if it is installed, you need to set some EVN variables ( JAVA_HOME, etc.. ). Check the installation instructions
1

To compile do java SimpleProgram

If you dont want to do this back and forth get Textpad!

Comments

1

Follow this step by step tutorial- http://www.youtube.com/watch?v=5u8rFbpdvds

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.