简体   繁体   中英

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 -

Class 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:-

 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

but gives error with command - javac -classpath "." com/bharat/Test2.java

error :-

javac: file not found: com/Bharat/test2.java Usage: javac use -help for a list of possible options

enter image description here

What wrong am i doing ?

在代码中,您定义了包com.bharat之类的包,可以将其更改为com.Bharat包,还是尝试将目录重命名为小写字母

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