Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to setup "Main Class" in "Run Configurations" in Eclipse

Tags:

java

eclipse

In a Java project, there have two java files has main method. The absolute paths for these two java files are:

C:\Desktop\project1\src\com\pre\moveposition1.java

And

C:\Desktop\project1\src\com\pre\moveposition2.java

When I try to setup “Main Class” parameter in “Run Configuration”, what should I setup?

enter image description here

like image 634
user288609 Avatar asked Jul 01 '13 04:07

user288609


Video Answer


2 Answers

Put the (fully qualified) name of the class containing main. For example, if you want to use moveposition2's main (and not moveposition1's) then you'd enter:

com.pre.moveposition2

Also, clicking on "Search..." should give you a list of classes that contain main() methods that you can choose from.

like image 175
Dave Lillethun Avatar answered Oct 18 '22 07:10

Dave Lillethun


If both classes have a main() method, you can only run one at a time, since they are effectively two distinct programs.

So, in the Run Configuration, you choose either moveposition1 or moveposition2. If you later want to run the other one, just right-click on it and select Run As...->Java Application. You will now have two run configurations for your project.

like image 22
mikołak Avatar answered Oct 18 '22 07:10

mikołak