-1

Trying to run a simple file called Test.java from the cmd. by javac Test.java it appears to run, but nothing is printed to the terminal?

public class Test {
    public static void main(String[] args) {    
            Integer a = 1000, b = 1000;  
            System.out.println(a == b);
            Integer c = 100, d = 100;  
            System.out.println(c == d); 
    }
}
JonCode
  • 241
  • 1
  • 8
  • 20

3 Answers3

2

javac will compile the file, you need to run it by java Test

Executing javac will only create the compiled bytecode file, named Test.class

Solomon Slow
  • 25,130
  • 5
  • 37
  • 57
Atri
  • 5,511
  • 5
  • 30
  • 40
2

To compile and run your class Test.java you should do this.

javac Test.java --to compile

and

java Test  -- to run

you can take a look at this link

Abdelhak
  • 8,299
  • 4
  • 22
  • 36
2

The javac command in Java compiles a program from a command prompt.

javac Test.java

Since nothing is printed to the terminal, we will assume it did not have any errors.

The java command from a command prompt runs the program.

java Test
byteherder
  • 331
  • 2
  • 9