Eclipse executes invalid java file

I use Eclipse to write and test Java. I am new, so I don’t know anything about Eclipse.

The problem occurs when I try to run the Java file that I just wrote. Instead of launching the file that opens, it executes the file that I successfully executed before. I have several files in the same package by default. Package Explorer shows that my package location is: Aayush> src> default package

I want to run a file with a name logicaloperator.java, but it launches ifstatement.java, both of them are in the same package by default, and I use the 6th button on the toolbar to launch it. When I press the start button, it says: “run ifstatement”, but you need to say “run the logical operator”.

+7
source share
10 answers

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

2. If you still have problems, right-click on this java file in the package explorer and selectRun

3. Save the class name that contains your main () method and the name of the file with which you save your file in Eclipse as MOST.

logicaloperators.java logicaloperator.java...... "s"

:

class logicaloperators{


      public static void main(String[] args){

   }
 }

logicaloperators.java

+9

Java , (String [] args) .

→ RunAs → Java Application.

+1

, main() .

Eclipse , public static void Main(String[] args), .

+1

, . CamelCase , . . Java, ( , ). . , . Eclipse - , !

0

, "" - ! , 'static void main(String args[])' 'public ststic void main(String args[])'

0

, , , . , , , .

, , main(), " ", - .

, main() , ... main(String args) , .

... main (String[] args), .

0

Netbeans . . - " ". "" , " ", "".... , " " (, , , , ). , , , , .

0

angular Run Eclipse. , , . , logicaloperator.java , , , main() logicaloperator.java.

0

, :

public static void main()
{
    // ...
}

:

public static void main(String[] args)
{
    // ...
}
-2

Eclipse.

Eclipse, , .

, .

:

  1. Or try putting the classes with the main methods in different packages.
  2. Just restart the eclipse and restart the application (this always works for me).
-2
source

All Articles