简体   繁体   中英

Compiling mutiple files from command line in Java

I am a beginner in Java and I've built a class "Employee" and a test program "EmployeeTest". From the command line, I have typed javac *.java. It compiled both files and created Employee.class and EmployeeTest.class. How do I run those now?

Thanks so much

假设 Employee.class 和 EmployeeTest.class 在同一个目录中,并且都没有指定包(它们使用默认包)并且 EmployeeTest.class 包含 main 方法......你可以使用这个:

java EmployeeTest

The easiest way is to install an IDE which contain a compiler, interpreter, or both, such as NetBeans and Eclipse.

You will be able to run and compile your code easily.

You can run your application using the java <Classname> command. Replace the class name property with your own, eg EmployeeTest . If you are having problems, watch your case, since the class name is case sensitive. Also omit the .java file extension, Java needs to know the class name here.

So in your case, try running this from the command line:

java EmployeeTest

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