0

I have written a simple java program on mac and compiled using javac option. To demonstrate it's platform independent, I copied the .class file to a windows machine (via email) and run java . However, it's giving error saying could not find or load main class...

I compared the java version on both mac and windows; both are same, except build version.

Below is the mac java version:

:~/Desktop/compare/javatest$ java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

Here is the simple java program:

public class Main {


    private int number1 = 0;


    public static void main(String[] args) {
        System.out.println("Hello World!");
    }

    void doSomething() {
        int number4=0;

        number4=number1+number1;

        int number2 =0;
    }
    int number3=0;
}

Attaching the error from windows machineenter image description here

Istiaque Hossain
  • 2,157
  • 1
  • 17
  • 28
Suvro Choudhury
  • 115
  • 1
  • 5
  • 18

1 Answers1

0

i also face this problem , then solve my problem by using this code

javac Test.java
java -cp . Test
Istiaque Hossain
  • 2,157
  • 1
  • 17
  • 28