简体   繁体   中英

cannot find symbol error when create object of another class in java without extends only in windows

I hava 2 java files.

First one is Sample.java

Second is Sample2.java

both codes are

Sample.java

public class Sample{
    int Number = 1000;
}

Sample2.java

public class Sample2{
    public static void main(String[] args) {        
        Sample obj = new Sample();
    }
}

When i compile sample2.java it shows the following error

在此处输入图片说明

I dont know what the problem is?. This same code run in linux. I using win 7 32 bit. is there need to change any settings in windows. My java version is 1.8.0.181.

Give me the answer to solve this problem

你必须把包含 Sample.class 的文件夹放到你的类路径中:

javac -cp ./ Sample2.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM