简体   繁体   中英

Why I can't run a .java file in the command line?

I'm trying to run this in the command line: java InOut There is a file InOut.java there, I can see it when I run the dir command. But I always get "Could not find or load main class InOut". What am I doing wrong? I'm using Eclipse by the way.

Thanks

Before you can run Java code, it must be compiled. Run the command javac InOut.java and then run java InOut .

Eclipse will automatically compile your saved Java files for you, so you don't actually need to do it on the command line. When running your programs in command line, you have to go to the bin folder, not the src folder. There, you should find InOut.class, and be able to run it.

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