简体   繁体   中英

intellij project with more than one classes having main method

在此处输入图片说明 I have an experimental project that used to write some ADT like stuff in which there are packages like linkedList, streams, sorting, stacks, sockets etc. Every class has own main method, Like in eclipse we can run the class from the option menu but how this can be done in intelliJ ?

You can create your run configuration for each main class from Run -> Edit configuration .

Here's the guide link

Editing answer because of comments below:

See this link: imgur.com/a/1H5Xhj8 Here I ran class A and B and I can see in run config menu. Now I created class JJ. I still can see green triangles on this class but not in dropdown. NB: I'm not using ultimate version but community edition. Hope it's not an issue

See, you can also run your public static void main directly like in eclipse. IntelliJ automatically have this run config. But to have this all you need to do is set your source folder.

So, File> Project Structure > Modules , the select src and mark as sources .

在此处输入图片说明

For more details : https://www.jetbrains.com/help/idea/creating-and-managing-modules.html

After you have done this, you will see small green triangles on left near your public static void main from where you can run and debug.

在此处输入图片说明

You see that J small icon on top of Java icons files in project window on left. This is indication that you have not configured your sources folder .

See : What does this symbol mean in IntelliJ? (red circle on bottom-left corner of file name, with 'J' in 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