[英]Compile Time error JAVA compiling multiple classes
i am trying to compile two .java files from CMD but i am getting error, the second files makes a reference and call a variable of first file, code is like - 我正在尝试从CMD编译两个.java文件,但出现错误,第二个文件进行引用并调用第一个文件的变量,代码如下-
Class 1 :- 第1类:-
package com.bharat;
class test
{
static int s =9;
public static void main(String[] args)
{
for(String c:args)
System.out.println(c);
//int a = int.parseint(s);
System.out.println(s);
}
}
Class 2:- 第2类:
package com.bharat;
class test2
{
public static void main(String[] args)
{
for(String c:args)
System.out.println("test2");
String p ="abc";
System.out.println(p);
test t = new test();
System.out.println(t.s);
}
}
` compiles fine with command - javac -classpath "" *.java and javac -classpath "" Test.java Test2.java ` 使用命令编译良好 -javac -classpath“” * .java和javac -classpath“” Test.java Test2.java
but gives error with command - javac -classpath "." 但给出命令错误 -javac -classpath“。 com/bharat/Test2.java
COM /巴拉特/ Test2.java
error :- 错误:
javac: file not found: com/Bharat/test2.java Usage: javac use -help for a list of possible options javac:找不到文件:com / Bharat / test2.java用法:javac使用-help列出可能的选项
enter image description here 在此处输入图片说明
What wrong am i doing ? 我在做什么错?
在代码中,您定义了包com.bharat之类的包,可以将其更改为com.Bharat包,还是尝试将目录重命名为小写字母
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.