简体   繁体   中英

How to run Java program through the terminal in IntelliJ

I know how to run and compile a basic Java program in the terminal using java and javac .

I also know how to run and compile a Java program using IntelliJ.

However, how do you run a program in an IntelliJ project using the terminal.

So far all my classes is compiled to a "out/production/myproject" folder by default in Intellij. So far I have tried the following command in the above folder:

java Main

However for some reason it says:

Error: Could not find or load main class Main

When you run a program in Intellij, in the run window (bottom panel) the very first line is what intellij terminal command. The line usually is shortened like this:

/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/bin/java...

If you click on it, it will show you full command that Intellij runs.

在调用java Main之前,您必须指定类路径。

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