[英]cannot find symbol error when create object of another class in java without extends only in windows
I hava 2 java files.我有 2 个 java 文件。
First one is Sample.java第一个是 Sample.java
Second is Sample2.java其次是 Sample2.java
both codes are两个代码都是
Sample.java示例.java
public class Sample{
int Number = 1000;
}
Sample2.java示例2.java
public class Sample2{
public static void main(String[] args) {
Sample obj = new Sample();
}
}
When i compile sample2.java it shows the following error当我编译 sample2.java 它显示以下错误
I dont know what the problem is?.我不知道是什么问题?。 This same code run in linux.同样的代码在 linux 中运行。 I using win 7 32 bit.我使用的是 win 7 32 位。 is there need to change any settings in windows.是否需要更改 Windows 中的任何设置。 My java version is 1.8.0.181.我的 java 版本是 1.8.0.181。
Give me the answer to solve this problem给我解决这个问题的答案
你必须把包含 Sample.class 的文件夹放到你的类路径中:
javac -cp ./ Sample2.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.