Running a java program on the command line

- Background information:

I recently started learning the basics of the Java programming language. To run my program on the command line, I downloaded the java development kit, also known as the JDK, and I installed my system path for Windows 10:

C: \ Program Files \ Java \ jdk-9.0.1 \ bin; C: \ Program Files \ Java \ JRE-9.0.1 \ Bin

- Problem:

After writing a simple Hello World program with the following format:

    class test{

        public static void main(String[] args){

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

and run it on the command line using

javac test.java

and then recording

java test

output says:

Error: the main method is not static in the test class, please define the main methods as:
public static void main (String [] args)

I tried to build my simple program in an online Java compiler and everything works fine.

- Change:

Java. http://www.javadecompilers.com/result   :

    import java.io.PrintStream;

      public class test { 
          public test() {} public void main(String[] paramArrayOfString) { 
               System.out.println("Hello World!"); 
          }
      }

- :

? ?

+4
1

:

"Sublime Text 3" test.java. @Silvio Mayolo java , , Sublime test.java - . :

  • 3
  • test.java, . , , void main (String args) {}.
  • , static void main (String [] args) {}
  • .
  • javac test.java , java test, , .
0

Source: https://habr.com/ru/post/1691338/


All Articles