Reputation: 802
I recently upgraded to Eclipse Kepler, and am having issues with Ant. I am getting the Java Virtual Machine Launcher - A Java Exception has occurred error no matter which target I choose in my build files.
I tried reinstalling my JDK, and I still get the error. I am running the 7u25 version of the JDK. I have my JAVA_HOME environment variable set to C:\Progra~1\Java\jdk1.7.0_25
, so I don't think this is the problem. What else could be causing the problem?
EDIT: I also tested ant in the command line and it works just fine. Is this a bug in Kepler?
EDIT 2: Here is the log of the errors:
org.eclipse.core.runtime.CoreException: Could not find one or more classes: "org.apache.tools.ant.BuildLogger". Please check the Ant classpath.
at org.eclipse.ant.core.AntRunner.problemLoadingClass(AntRunner.java:467)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:380)
at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.runInSameVM(AntLaunchDelegate.java:307)
at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate.launch(AntLaunchDelegate.java:260)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:858)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:700)
at org.eclipse.core.externaltools.internal.model.ExternalToolBuilder.launchBuild(ExternalToolBuilder.java:181)
at org.eclipse.core.externaltools.internal.model.ExternalToolBuilder.doBuildBasedOnScope(ExternalToolBuilder.java:169)
at org.eclipse.core.externaltools.internal.model.ExternalToolBuilder.build(ExternalToolBuilder.java:88)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:514)
at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:423)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:830)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1018)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1222)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildLogger
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:324)
... 24 more
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildLogger
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at org.eclipse.ant.internal.core.AntClassLoader.findClass(AntClassLoader.java:54)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 29 more
Upvotes: 12
Views: 21849
Reputation: 939
I have had same problem, probably caused by switching between two versions of Eclipse but using same workspace. This has worked safely for some time, but suddenly, the exception was raised.
I deleted the .metadata folder in the workspace folder.
I set up my workspace again: close all the annoying useless Eclipse default tabs, import existing project, set Ant home directory in Ant...Run Configurations etc.
Upvotes: 0
Reputation: 16146
I had this problem recently (then a colleague) in Eclipse when running an ANT script from the UI interface (context menu, Run As
or Debug As
).
Due to some reason, the Runtime JRE for the ANT script (or for ANT itself, unclear at this point) got changed. This Runtime JRE can be changed from the context menu for the ANT script, External Tools Configurations...
:
Then move on to the JRE tab on the right side:
My colleague had the Separate JRE
setting wrong, changed it to the proper JRE setting (JDK 1.8_XXX in his case). This was after a merge, where apparantly some incorrect settings were merged into a branch (or so we think).
In my case, I think I had this set as Run in the same JRE as the workspace
which was wrong. I also set this to Separate JRE
, chose the proper 1.8 JDK and that fixed the issue. This was after an upgrade of the Eclipse version (as I recall).
Upvotes: 0
Reputation: 13736
IDE like (Eclipse-Oxygen) will have default ant versions. If your ant build XML is not compatible with higher version of ANT.
Lower/Higher the ANT version to the suitable one. JDK is not compatible with all ANT Builds. For Instance, ANT 1.9.2 is the last version to support JAVA 7.
So we need to match the JDK version and ANT version's respectively. Override the IDE default version using Preferences -> ANT -> Runtime -> Click on Ant Home (and choose the new version of ANT Home there, that will override the Ant Home Entries)
Upvotes: 4
Reputation: 660
For me the problem were the JDK I were trying to use. The project I wanted to build was setup to use the 1.6 JDK. I got the same error as the questioner, but when I changed to Java 8 the build worked fine. So I am assuming that the ANT version that comes with newer versions Eclipse does not work with older JDKs.
Upvotes: 4
Reputation: 6428
In my case ant home was pointing to a symbolic link (to a real ant installation). Eclipse didn't like that. Updating to the actual installation folder solved the issue.
Upvotes: 0
Reputation: 2086
This is most likely due to difference in Ant version being used by eclipse. Please update Ant_Home in eclipse . Window --> Preferences --> Ant --> Runtime --> Classpath -->Click Ant Home.. and try to locate the latest version of Ant directory location. This works for me :)
Upvotes: 15
Reputation: 2609
For me, I just delete the metadata folder and start eclipse with import all of your library project. Check your ant class path and add this jar again. Thanks
Upvotes: 0
Reputation: 33
I had the same error; switched workspace from Eclipse Indigo to Eclipse Kepler. I was able to resolve it by resetting the Ant_Home value. It was originally pointing to the correct folder, but I just reset it to the same folder and clicked on 'Apply'. Works fine now. Hope this helps.
Upvotes: 1
Reputation: 359
In my case :
Due to the re-use of a old workspace with a different Eclipse version, i solved by replacing all jar dependency in Ant->Runtime->Classpath->Ant Home Entries (Default) by reals and existing jar (from my eclipse-jee-kepler-SR1-win32-x86_64\eclipse\plugins\org.apache.ant_1.8.4.v201303080030\lib)
It's explain on : https://bugs.eclipse.org/bugs/show_bug.cgi?id=102463#c41
Upvotes: 2
Reputation: 71
I had the same problem and it kept me a while to figure out what the solution is. I followed all the suggestion on this page and similar pages; nothing helpt! I uninstalled and installed jdk, eclipse, reset my project, I forced Eclipse clear it's parameters, ...; no success.
What finally fixed my problem was deleting the .metadata directory in the workspace folder. I don't know what eclipse keeps in there, but deleting the .metadata direcotry caused Eclipse reinitiate every setting. I did have to reimport my project structure. It works again like a charm. No vague 'There is an exception occured' error message.
Upvotes: 7
Reputation: 3329
Possible that Eclipse does not have the correct JAR defined. Did you try to add the tools.jar needed for Ant?
Preferences > Ant > Runtime
Upvotes: 0