I have a main method in a package in one of my projects. Say, the package is com.ant.car. I am trying to run and/or debug this main method, and I keep getting the error Could not find or load main class com.ant.car.
I've searched this problem, and it seems like I can't figure out what is wrong.
1) I've checked run configurations. In Run->Run Configurations, I've checked that the Main class is com.ant.car.
2) I've checked build path. If I right click on the project, I select Build->Build Path, and under the Libraries tab I make sure there are no missing folders with red Xs next to them.
Not really sure what else to do. Any suggestions?
Project -> Clean
this is working
Try updating project by right clicking on it. Maven -> Update Project
Today I ran into the same problem and I tried a lot of answers. Nothing helped. Cleaning the project, build automatically is already checked, deleting .metadata, etc.
Eventually I tried this and it worked perfectly:
menu Project -> Properties
Java Build Path, tab Libraries
Remove the JRE System Library from there, press Add Library, take the JRE System Library and press Next. Workspace default JRE and press Finish.
What worked for me:
Menu Project -> Properties
In Java Build Path, tab Libraries
Delete all libraries with a red [x] next to them.
In my case, problem happened when I switched from Kepler to STS IDE.
The solution to this was the following:
Close Eclipse/STS
Use a file explorer on your operating system to navigate to your workspace (In my case, I'm on Windows so I used Windows Explorer)
Delete the .metadata directory (or to be safe, copy the directory somewhere else to be safe, then delete it)
Restart Eclipse/STS
Is there a more improved answer than this? I don't want to look like I'm trying to boost my own reputation points, so if someone can provide a better answer then please do so.
Sometimes the problem can be caused by some newly added dependencies. Try removing the recently added jars. That's how I fixed my problem.
Project -> Clean... -> check project not working -> Clean
I already had build automatically set, but forcing STS to rebuild it fixed it.
This issue occurs when the main .class file moved or not found because you changed the directory for committed/shared the project into the git or another repository.
To Resolve this issue -->
Remove existing run configuration and new one.
Find the parent pom.xml or project pom.xml and open cmd/command prompt and run the below commands,
mvn clean install package
mvn eclipse eclipse
It worked for me:
1. Delete metadata from work-space directory.
2. Import the project again, but selected copy to work-space option.
I think the cause for the error was Non-English characters in the original saved directory.
You just need to delete Run Configuration file and restart STS and run command -mvn clean install and try to restart the service
The Error "Could not find or load main class com.ant.car" occur when your class is not in build path. please make sure that .class file is generated and it's in build path ..
I faced the same issue..
just do follow these steps:
STS/Eclipse --> Project --> Enable "Build Automatically"
then refresh your project, it will resolve your issue.
Still not refreshed your projects automatically, just restart your STS and check.
Hope it will help you.
I think .class files are deleted/missing from JavaProject/bin folder.
To resolve this issue ->
1) Just cut paste and save the code contents of all the files that you are using then .class files will be regenerated.
2) Then run the code and you can see it works fine if there is no syntactical errors.
1 ) Clean the Project
2 ) Enable build automatically Option
3 ) Update the maven project by use the short cut Alt + F5
Deleting target folder manually and mvn clean install worked for me
A quick and easy fix is to directly run your SpringBootApplication class (i.e. Right click, Run As -> Spring Boot App). This runs the app and creates a run configuration automatically.
I spent several hours on this issue, finally it is fixed by doing this:
Properties -> Java Compiler: uncheck the checkbox "use '--release' option"
This worked for me to solve the error. (I got this error after removing AWS ToolKit)
Close the Eclipse/ STS Eclipse.
Go to the WorkSpace folder.
Delete the .metadata folder.
Open the eclipse.
Run maven install on pom.
Run the project with your Run configuration.
Remove project from STS/Eclipse
Close or Refresh the Eclipse/ STS Eclipse.
Run maven install on pom.
Run the project with your Run configuration.
Tried above mentioned steps to resolved issue.
You can try one of the two solutions below:
Solution 1: Right click the project -> Gradle -> Refresh Gradle Project.
Solution 2: Add gradle or maven in your environment variable. My problem was that I had not added gradle in my environment variable. Before, make sure Gradle or maven is installed in your OS.
I tried all the answers but finally what worked for me was deleting the project from eclipse workspace and importing it again.
I restarted my computer, and rebooted my VM with Ubuntu 12.04 on it and, I restarted Eclipse. Then I noticed that there were errors regarding the build, so I did a 'mvn clean install' on the repo in the terminal, and after that I re-imported the Maven project in Eclipse (when the option was still available). After the import finished I noticed that it said that mvn is missing the 'unpack' command in m2e. So I thought, that I needed to update the software so I went into Help > Check for Updates, and then I guess it found a better version of m2e, but now the 'Import Existing Maven Project' is gone now. I tried importing it regularly, however the 'src/java/main' and 'src/java/test' aren't distinguished as different special folders.
Has anyone else encountered this issue? If so, what did you do to solve the problem.
Thanks in advance,
ejay
If you right cliok the project and select Configure, does it offer to convert the project to Maven nature?
Generally, using the "clean" option on any tool will delete files and folders that are considered "secondary", i.e. they can be recreated easily. That might include some config files in this case.
I have created a plugin project in eclipse to create a new category and view. I run the MANIFEST.MF file as an eclipse application which opens a new eclipse window and I can see my plugin take affect. However, I want the plugin to be part of my standard eclipse installation.
For this I have exported the project to a jar, put the jar in the plugins folder and restarted eclipse. But I cannot see the changes take affect. I have also tried running eclipse from the command prompt with -clean option to force eclipse to search for new plugins. I have also tried putting the jar file in the dropins folder and restarting but nothing is working.
Any idea on what I might be missing ? I know the other option is to create feature but I wanted to understand what is wrong or missing in my approach.
Regards,
Dev
Try starting Eclipse with OSGI console (eclipse -console) and see if it gives any errors or warnings.
See this answer on SO.
When I run my program in debug mode and try to use hot code replace feature, it just doesn't change anything in running application and there no error window is shown. I am using eclipse version 3.6.2, JVM 1.6 and Windows 7. I have "Build Automatically" checked, I unchecked "Abort build when build path errors occur", but nothing helps. (And I am not creating/deleting methods or something like that.)
Right click on the project. Go to properties->Java Build Path->Projects tab. See if there is any project dependency which does not exist. Remove those projects.
Try hot deployment again. For me that fixed the issue.
Check if Build Automatically is ticked (✓). This would Build your project automatically on Hot code replacement. This worked for me!
I'm struggling a bit, trying to properly setup my maven projects in an IDE.
I don't particularly care between Eclipse and IntelliJ, but it seems that IntelliJ handles much better when it comes to import my projects, so I think I will stick with this one.
I'm having other problems now when trying to run the install goal through IntelliJ.
The first error :
The svn command failed. Command output: 'svn' is not recognized as
an internal or external command, operable
program or batch file.
How do I configure IntelliJ in order to let him see svn ? This error sounds weird to me, as I have installed Subversion as my Version Control System in IntelliJ.
Also, and this is related, I have a setenv.cmd that I usually run from the commandLine before calling mvn install. It only sets some variable like :
PROJECT_HOME=d:\Project\xxx\xxx\Trunk
PROJECT_VERSION=0.4.3-SNAPSHOT
M2_HOME=d:\Java\apache-maven-2.0.11
JAVA_HOME=d:\Java\jdk1.5.0_11
PYTHON_HOME=d:\Python26
XOOOF_HOME=d:\Project\xxx\xxx\XOOOF-BIN-1.0.3
XOOOF_URL=file:///d:/Project/xxx/xxx/XOOOF-BIN-1.0.3
SVNCLIENT_HOME=d:\Java\svn-win32-1.6.3
CATALINA_HOME=d:\Java\apache-tomcat
PATH=C:\WINDOWS;C:\WINDOWS\system32
How could I improve this step, and find a way to make it work from my IDE ?
Thanks !
If you want to do maven builds in eclipse I would strongly suggest installing m2eclipse by Sonatype.
It has an excellent reference on how to use it -> http://www.sonatype.com/books/m2eclipse-book/reference/
Regarding the first error it seems to be not Idea fault. AFAIK Idea doesn't need/use external SVN binaries. What happens when you click "9: Changes" tab at the bottom in Idea? If you make your project/module as managed by SVN there should be Repository subtab.
You run Maven from Idea to perform install goal and that error seems to come from it. Do you use SCM/SVN plugin in pom.xml? If yes or you would like to have an ability to run SVN from command line add directory with svn.exe (d:\Java\svn-win32-1.6.3? d:\Java\svn-win32-1.6.3\bin?) to PATH (not only to SVNCLIENT_HOME). After that operation svn command from new "run window" should be recognized.