I know it's no longer an issue for the original poster but new programmers may run into this.
You likely forgot to add String[] args in your main method. This means the program will default to running another class, likely whatever was ran last.
public static void main(String[] args) {
}
This was a really basic issue that anyone with decent experience would likely not think of hence what I assume to be the reason for the lack of replies.
P.S. I just jumped back into coding and ran into this a couple minutes ago.
Answer from UnskilledUnityCoder on Stack OverflowI know it's no longer an issue for the original poster but new programmers may run into this.
You likely forgot to add String[] args in your main method. This means the program will default to running another class, likely whatever was ran last.
public static void main(String[] args) {
}
This was a really basic issue that anyone with decent experience would likely not think of hence what I assume to be the reason for the lack of replies.
P.S. I just jumped back into coding and ran into this a couple minutes ago.
You can try right clicking on java file(Balloon) and select Run As java application(it will show this option if you have main method in class).
It did not work then clear the workspace and try to import the project once again. there is chance you have corrupted the workspace.
Eclipse: Could not find or load main class?
Can't compile/run in Eclipse- Java - Stack Overflow
compilation - Eclipse won't compile/run java file - Stack Overflow
java - Eclipse can't find / load main class - Stack Overflow
I've never gotten this issue before when running Java in Eclipse. Here is my run config and a simple main function to test. Any help would be great!
https://imgur.com/a/8yd6gp7
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
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
- 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!
.metadata is corrupted.
Steps:
Warning: Deleting .metadata will delete all your Eclipse configurations, plugins, project setups. Make a backup before you attempt this!
Stop eclipse, delete .metadata in workspace and restart eclipse
Import Project
Run again
Removing the Run Configuration
Sometimes I have a similar problems in some pre-release versions of eclipse. For fix the error, I delete the Run Configuration. You can find that in menu Run, Run Configurations...
Then I launch the app with Alt+Shift+X, then J. If this don't work, Ctrl+F11.
Deleting the
.metadatadirectoryIn another way, the configuration settings for your current workspace may are corrupted. Those settings are in the
.metadatadirectory in your current workspace 1. In that case, there is no other choice than delete the directory:- Close eclipse.
- Delete the
.metadatadirectory. - Start eclipse.
- Import the projects.
- Run the project again.
Notes
- You will see that directory with File > Switch Workspace > Other...
Do this as follows
- First, you need make sure the java file name has the same as your class name. see the red circle in the screen shot below.

- Right click on your source code. Run As> Run Configurations... then in Run configuration pop up window, you need make sure that it is filled up with the right project name and Main class name, which is ParmsConsDemo in your case. see the screen shot below:

Make ParmsConsDemo public.
...
public class ParmsConsDemo {
...
public static void main(String[] args){
..
}
...
}
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();
}
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.
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.
If you create a java class with public static void main(String[] args), Eclipse will run that main method for you by right clicking on the file itself, or on the file in the project explorer, then choosing:
"Run As" -> "Java Application."
Once you do this, Eclipse stores information about your class, so you can easily run the class again from the Run As menu (Green Play Button on the toolbar) or from the Run Configurations dialog.
If you subsequently MOVE the java class (manually, or however), then again choose
"Run As" -> "Java Application,"
from the new location, Eclipse will run the original stored configuration, attempt to invoke this class from its original location, which causes this error.
SOLUTION:
For me, the fix was to go to the run configurations, (Green Play Button -> Run Configurations) and remove all references to the class. The next time you run
"Run As" -> "Java Application"
Eclipse will write a new configuration for the moved class, and the error will go away.
tl;dr: Clean your entire Build Path and everything you ever added to it manually. This includes additional sources, Projects, Libraries.
- Project -> Clean
- Make sure Project -> Build automatically is active
- Project -> Properties -> Java Build Path -> Libraries: Remove any external libs you have ever added. Don't remove standard libraries like the JRE System Library.
- Try to run your main class now. The "class could not be found / load" error should be gone. Try adding your external libs/jars one after each other.
Reason behind this: The compiler had issues linking the libraries to the project. It failed and produced a wrong error message.
In my case, it should have been something like "Could not add AutoHotkey.dll to the build path" because that was what made the compiler fail.
If this is still not working, have a look at the built-in ErrorLog of Eclipse:
Window -> Show View -> General -> Error Log
