First make sure that you made a regular "Java Project", and not something else.
If there's something wrong with the build configuration, which i guess there is, go to: Run > Run Configurations... On the left you will see a list of configurations, make sure your configuration runs as a "Java Application". If not, delete all the configurations by selecting them and then press delete.
If things are fine, your program should run normally
Answer from Hugo Kerstens on Stack OverflowFirst make sure that you made a regular "Java Project", and not something else.
If there's something wrong with the build configuration, which i guess there is, go to: Run > Run Configurations... On the left you will see a list of configurations, make sure your configuration runs as a "Java Application". If not, delete all the configurations by selecting them and then press delete.
If things are fine, your program should run normally
Create a Java Project by menu: File > New > Java Project
Only the Project name is mandatory (if needed, you can configure all other options later).Browse to your new project, and select the src folder.
New > Package
New > Class
Make sure to select the checkbox to create: public static void main(...) This creates a runnable class.Put some sample code to main(), e.g.:
System.out.println("HALLO");
Select the class in Package Explorer and Run As > Java Application
Hi,
I have written a simple Java application. However, when I execute the application, I get some other application being executed. My code is given below:
//Convert int to Integer
import javax.swing.*;
public class IntToInteger {
int iA;
IntToInteger(int iA){
this.iA = iA;
}
void ConvertIntToInteger(int iA){
Integer iRes = Integer.valueOf(iA);
JOptionPane.showMessageDialog(null, " "+ iRes);
}
}Some body please guide me.
The image is attached at:
https://ibb.co/r5dGVZt
Somebody please guide me.
Zulfi.
java - Program in Eclipse not Running - Stack Overflow
java - Eclipse programs not running? - Stack Overflow
compilation - Eclipse won't compile/run java file - Stack Overflow
Why Is My Eclipse Java Program Not Running - Error Message: "Error: Could not find or load main class" - Stack Overflow
" what is happening is I go to open file.."
You don't want to open the file. You want to open the project
- Click on File menu
- Click on import
- Click on General
- Select on Existing Projects into Workspace. CLlick Next
- Click Browse to search from your project
- Select the Project, Click OK
- Click Finish
The project should now show in your package explorer and you can then run it.
To run program JRE is enough.
If you want to build project you need JDK.
Eclipse is a Java application and it works without JDK,but it needs JDK to build a project.
Eclipse is not compiler or something like that, it's only an IDE.
- Make a project to put the files in.
- File -> New -> Java Project
- Make note of where that project was created (where your "workspace" is)
- Move your java files into the
srcfolder which is immediately inside the project's folder.- Find the project INSIDE Eclipse's Package Explorer (Window -> Show View -> Package Explorer)
- Double-click on the project, then double-click on the 'src' folder, and finally double-click on one of the java files inside the 'src' folder (they should look familiar!)
- Now you can run the files as expected.
Note the hollow 'J' in the image. That indicates that the file is not part of a project.

I was also in the same problem, check your build path in eclipse by Right Click on Project > build path > configure build path
Now check for Excluded Files, it should not have your file specified there by any means or by regex.
Cheers!
Had the same problem. I apparently wrote the Main wrong:
public static void main(String[] args){
I missed the [] and that was the whole problem.
Check and recheck the Main function!
You can try and add a new run configuration: Run -> Run Configurations ... -> Select "Java Appliction" and click "New".
Alternatively use the shortcut: place the cursor in the class, then press Alt + Shift + X to open up a context menu, then press J.
If the project is already imported in your workspace, Right click on your and Configure > Convert to Maven... This will enable the Maven builder and force m2e configurators to setup all the required project natures on your project.
You can also install the m2eclipse-git connector to streamline the "import maven project from git" process. It should be available from Preferences > Maven > Discovery > Open Catalog.
Once it's done, you should import your project via Import...> Maven > Checkout Maven Projects from SCM
Keep in mind that projects imported from GIT are not necessarily java projects, as Eclipse understands this term. Is the project, as it exists in the repository, an Eclipse project? If it is, it should have two files in its root folder named .classpath and .project. If these two files are missing, you will need to instruct Eclipse to create them, with logical defaults. Also, if the root folder of the project has a pom.xml file, then it is a maven project, which is a whole different kettle of fish.
The class to be executed needs a method with the following signature: public static void main(String[] args).
You need to create a main method. When you execute a class, the runtime system starts by calling the class's main() method, so without it your class will not get executed.
So you need to add the following code to the class you are trying to run:
public static void main(String[] args){
ClassName c = new ClassName();
}