Keywords: Eclipse | Java | JVM | eclipse.ini | exit code 13
Abstract: This article provides an in-depth exploration of the "Java was started but returned exit code 13" error in Eclipse, covering causes such as Java version incompatibility and 32-bit vs. 64-bit JVM mismatches. It offers detailed steps for configuring the eclipse.ini file, including correct -vm path specification and Java version parameter adjustments. Drawing from multiple real-world cases, the guide helps developers quickly diagnose and resolve startup issues, ensuring a stable development environment.
Error Background and Common Causes
When users uninstall Java 6 and install Java 7 (including both JDK and JRE), Eclipse may fail to start with the error "Java was started but returned exit code 13". This error typically stems from misconfigurations in the Java development environment, primarily involving the following aspects:
- Java Version Incompatibility: The Java version required by Eclipse does not match the installed JDK or JRE on the system. For instance, Eclipse might require Java 1.7, but the system defaults to an older version or is not configured correctly.
- 32-bit vs. 64-bit JVM Mismatch: If Eclipse is a 64-bit version but the specified JVM is 32-bit (often located in the
Program Files (x86)directory), startup will fail, and vice versa.
In the user case, the initial error was "No JVM found". The user attempted to resolve it by adding a -vm path (e.g., C:\Progra~2\Java\jdk1.7.0_45\bin\javaw.exe) and modifying -Dosgi.requiredJavaVersion=1.7 in the eclipse.ini file, but exit code 13 persisted. This indicates that the path or version configuration might be inaccurate.
Core Solution: Proper Configuration of eclipse.ini File
To resolve this error, the key is to correctly edit the eclipse.ini file, ensuring accurate JVM path and version parameters. Below are steps based on best practices:
- Locate and Edit the eclipse.ini File: This file is typically in the Eclipse installation directory. Open it with a text editor, ensuring the file encoding is UTF-8 or system default to avoid parsing errors.
- Add or Correct the -vm Parameter: Add a
-vmline followed by the path to the JVM executable. The path should point to thejavaw.exein the JDK, not the JRE, to ensure a complete development toolchain. For example:
Note: Use the full path, avoiding abbreviations (e.g.,-vm C:\Program Files\Java\jdk1.7.0_45\jre\bin\javaw.exeProgra~2), to prevent system recognition issues. The parameter must be placed before-vmargs, typically after lines like--launcher.appendVmargs. - Adjust Java Version Requirements: Check and modify the
-Dosgi.requiredJavaVersionparameter to match the installed Java version. For Java 7, set it to-Dosgi.requiredJavaVersion=1.7. This ensures Eclipse validates JVM version compatibility during startup. - Verify Path and Permissions: Confirm that the specified
javaw.exefile exists and that the Eclipse process has permission to access it. In Windows, retain spaces in paths, as the system handles them automatically.
Example snippet of an eclipse.ini file:
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-product
adtproduct
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
C:\Program Files\Java\jdk1.7.0_45\jre\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Xms40m
-Xmx768mIn this example, the -vm parameter correctly points to the JRE javaw.exe in JDK 7, and the version parameter is updated. Note: Backslashes in paths may need escaping or use of forward slashes in configuration files, but in Windows, backslashes are commonly used directly.
In-Depth Analysis: Error Mechanisms and Prevention Measures
Exit code 13 generally indicates JVM startup failure, potentially due to:
- Incorrect Path: If the
-vmpath points to a non-existent file or directory, Eclipse cannot launch the JVM. Using full paths and verifying file existence can prevent this. - Architecture Mismatch: A 64-bit Eclipse requires a 64-bit JVM. If the path points to a 32-bit JVM (e.g., in
Program Files (x86)\Java), compatibility issues arise. Check the bitness of both Eclipse and JVM to ensure consistency. - Parameter Order Issues: The
-vmparameter must precede-vmargs; otherwise, the JVM may not initialize correctly. The Eclipse launcher parses parameters in sequence, and incorrect order can cause failures.
To prevent such errors, it is advisable to:
- Back up the
eclipse.inifile before upgrading Java. - Use the
JAVA_HOMEenvironment variable for JDK path management, but explicit paths ineclipse.iniare more reliable. - Regularly check compatibility between Eclipse and Java versions, referring to official documentation.
Supplementary Cases and Alternative Solutions
Beyond the primary solution, other answers provide additional insights:
- Path Selection: Some users suggest navigating directly to the
C:\Program Files\Javadirectory and selectingjre7\bin\javaw.exe, which works for pure JRE environments, but using the JDK path is more comprehensive. - Simplified Fixes: Certain approaches emphasize adding
-vmand the path before-vmargsonly, which is concise but may overlook version details.
In practice, combining system logs (e.g., Eclipse error logs) can further diagnose issues. For example, check application logs in Windows Event Viewer for detailed error messages.
Conclusion
The "Java was started but returned exit code 13" error is often caused by improper JVM configuration. By correctly editing the eclipse.ini file with accurate -vm paths and version parameters, it can be effectively resolved. Developers should ensure consistency in Eclipse and JVM versions and architectures, and adhere to parameter order rules. This guide, based on real-world cases, offers a complete workflow from diagnosis to repair, aiding in maintaining a stable development environment. If issues persist, inspect system variables or reinstall compatible components.