Could not find the main class: org.eclipse.ant.internal.launching.remote.InternalAntRunner. Program

在使用Eclipse更新至Mars版本后,尝试执行build.xml文件时出现错误提示'Could not find main class: org.eclipse.ant.internal.launching.remote.InternalAntRunner'。通过将JRE设置为与工作空间相同的环境解决了此问题。

Could not find the main class: org.eclipse.ant.internal.launching.remote.InternalAntRunner. 最近更新了eclipse,发现运行ant不好使来了,报的异常如标题所示。然后各种百度,尼玛!我只想说百度上写这些bug文档的人,能不能别乱写啊,艹。按照上面所说各种尝试,都不行。没办法,还是去Google吧。

I just installed Mars and when I tried to execute a build.xml after checking out an existing and working project I got that error message:

Could not find the main class: org.eclipse.ant.internal.launching.remote.InternalAntRunner. Program will exit.

The solution is to go to Run as → External tools configuration… → JRE where the default was set to “Separate JDK”: jdk1.6.0_31 (I had set up JDKs 6-8 in Preferences after installing). I changed this to “run in the same JRE as the workspace” and now it works.

Bug fix would be to provide a working default configuration with setup. Configuration should be in a way it does not break if the user adds additional JDKs to Preferences.

原文地址:https://bugs.eclipse.org/bugs/show_bug.cgi?id=472599。噢啦,问题搞定!

### 问题分析 用户遇到的错误信息是: ``` java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter ``` 这个异常通常出现在 Eclipse 或基于 Eclipse 的 IDE(如 Spring Tool Suite、MyEclipse 等)启动过程中,表示 JVM 无法找到指定类 `org.eclipse.core.runtime.adaptor.EclipseStarter`。该类属于 Eclipse 核心运行时组件,用于启动平台。 结合用户提供的日志片段中的信息: - 使用的是 Eclipse 版本 `4.7.2.M20171130-0510` - Java 版本为 `12.0.1` - 操作系统为 Windows 10 x64 可以推断出问题可能由以下几个原因导致: --- ### 可能的原因及解决方案 #### 1. **Java 版本不兼容** Eclipse 4.7(Oxygen)版本官方支持的最高 Java 版本为 Java 9,而用户使用的是 Java 12,这可能导致类加载失败或某些核心类找不到的问题。 **解决方法:** - 下载并安装与 Eclipse 4.7 兼容的 JDK/JRE 版本(推荐使用 Java 8)。 - 修改 `eclipse.ini` 文件,显式指定使用 Java 8 运行时路径,例如: ```ini -vm C:/Program Files/Java/jdk1.8.0_291/bin/javaw.exe ``` 确保 `-vm` 参数在 `-startup` 参数之前[^1]。 --- #### 2. **配置文件损坏或缓存残留** Eclipse 在启动时会读取 `configuration` 目录下的配置文件和插件元数据。如果这些文件损坏或存在冲突,可能导致类加载失败。 **解决方法:** - 删除 Eclipse 安装目录下的 `configuration` 文件夹(建议先备份),然后重新启动 Eclipse。 - 如果仍然无法启动,尝试创建一个新的工作空间,并通过 `-data` 参数指定新路径: ```bash eclipse -data "D:\new_workspace" ``` --- #### 3. **缺失关键插件或依赖项** `ClassNotFoundException` 也可能是因为缺少必要的插件 JAR 包,特别是 `org.eclipse.core.runtime` 插件未被正确加载。 **解决方法:** - 检查 Eclipse 安装目录下的 `plugins` 文件夹中是否存在以下 JAR 包: - `org.eclipse.core.runtime_<version>.jar` - `org.eclipse.osgi_<version>.jar` - 如果缺失,请从官网下载对应版本的 Eclipse 并替换相关插件包。 --- #### 4. **使用命令行参数修复启动器** 有时可以通过特定参数绕过部分初始化问题。 **解决方法:** - 尝试以清理模式启动 Eclipse: ```bash eclipse -clean ``` - 若仍无法解决,可尝试重建 OSGi 缓存: ```bash eclipse -clean -clearPersistedState ``` --- ### 示例操作步骤 1. **修改 `eclipse.ini` 文件内容如下:** ```ini -startup plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.551.v20171108-1834 -product org.eclipse.epp.package.jee.product -showsplash org.eclipse.platform --launcher.defaultAction openFile --launcher.appendVmargs -vm C:/Program Files/Java/jdk1.8.0_291/bin/javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.8 -Xms256m -Xmx1024m ``` 2. **删除 `configuration` 文件夹后重启 Eclipse** --- ### 预防措施 - 始终确保 Eclipse 版本与 Java 版本兼容。 - 定期清理 Eclipse 缓存或使用 `-clean` 启动参数维护。 - 不要随意更改 Eclipse 插件目录结构,避免手动删除或移动插件文件。 ---
评论 10
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值