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 logicaloperator.java
but it runs ifstatement.java
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".
Trying to guess your problem: When you press the Run as button (White arrow in green circle), Eclipse doesn't run the program you're editing. Instead, it runs again the last program you executed. That's the reason why you see the output of another project: You're telling Eclipse to repeat its execution.
Step 1: Open Eclipse and click File > New > Java Project. Step 2: Provide the Project Name and click on the Finish button. Step 3: In the Package Explorer (left-hand side of the window) select the project which you have created. Step 4: Right-click on the src folder, select New > Class from the submenu.
My program will not build or runMake sure the affected project is open, then go to Project->Preferences. Select the C/C++ Build pane, then make sure the build toolchain is using MinGW, not Cygwin. If you still have trouble running your applications, go back to Project->Preferences and look for the run/debug pane.
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 logicaloperators.java
NOT logicaloperator.java
......You have missed the "s"
Eg:
class logicaloperators{
public static void main(String[] args){
}
}
Save it as logicaloperators.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With