Skip to content

Eclipse is executing the wrong Java file

I am using Eclipse to write and test Java. I am a beginner so i don’t know anything about Eclipse.

The problem occurs when I try to run the Java file I just wrote. Instead of executing the file that is opened, it executes the file that I have successfully ran before. I have a few files in the same default package. The package explorer shows that the location of my package is: Aayush > src > default package

I want to run a file named but it runs both are in the same default package and I use the 6th button on the toolbar to run it. When I hover over the run button it says : “run ifstatement” but it should be saying “run logicaloperator”.



1. Please see that you have included the main() method in this class file.

2. If you still have the probs then right click on this java file in the package explorer and select Run

3. Keep the class name which contains your main() method, and the File name with which you save your file in Eclipse as SAME.

Its NOT……You have missed the “s”


class logicaloperators{

      public static void main(String[] args){


Save it as