123 @ qwe-Vostro-5468: ~ $ java Red.class Error: Could not find or load main class Red.class 123 @ qwe-Vostro-5468: ~ $ javac Red.java

123 @ qwe-Vostro-5468: ~ $ java Red.class Error: Could not

But actually my code that lies in Red.java:

public class Red { public static void main(String[] args) { int x = 1; while (x<2){ System.out.println("Doo"); System.out.println("Bee"); x = x + 1; } if (x == 1) System.out.println("Do"); } } 
  • one
    Manifest show - rjhdby
  • javac 1.8.0_111 - hellog888

1 answer 1

You need to call java Red , not java Red.class , because in this case the compiler will look for a class named Red.class