简体   繁体   中英

How to run my program in mac terminal (Intellij)

I have the following Java program in Intellij and I cant seem to figure out how to run the program from my mac terminal (or export everything to run it on a different computer). Currently the only way I can run the program is if I press RUN in the IDE. I assume I need a .jar file but where do I go to compile that? Any help would be greatly appreciated.

Open your project settings in the upper right corner (or ctrl+alt+shift+s) and go to "Artifacts". Then add Jar -> From modules with dependencies Choose your Module and your Main-class and Submit and apply the project settings

After that you can go to Build -> Build Artifacts -> Build IntelliJ creates the jar inside the "out" folder in your project folder.

(This is for simple Projects. If your project is a bit more complex, you might need more settings.)

@MadProgrammer: Before packaging a Java module into a JAR file, you need to configure an artifact of the type JAR. This artifact can define the output of one or more modules

Once I added the artifact and then build the artifact I am able to run the program via terminal

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