Anmol Anand's Weblog !!

Eclipse : Java was started but returned exit code = -1

I was having eclipse on my system (eclipse 3.6 – helios version), and a week ago, I decided to set it up for doing Android programming in Java.

When I opened Eclipse, I got the following error :

Java was started but returned Exit Code = -1

The error was same as shown in this image ( i have taken this image from the world wide web )

I googled this error and found that many people had faced the same error and there were many solutions available to this problem.

Most Common Solution : One of the most common solution that I found was of adding some lines to eclipse.ini file, For example: The path to the javaw.exe file. Adding some arguments to eclipse.ini file was also suggested.

This solution had solved the problem of many people, but, it lead to some other errors in my case( example : unable to find java virtual machine on the specified path).

I tried re-installing eclipse but the problem remained as it is.

Then, I decided to re-install my jdk and jre to the latest versions that were available.

I removed all the older versions and re-installed latest available versions of jdk and jre.

When I tried starting eclipse again, it started.

This solved my problem 🙂

If you are facing the same problem, then I suggest you give it a try once to re-install jdk and jre, and, see if it can help.

If this started happening when seemingly nothing has changed with respect to your eclipse and java installations, and there is a chance that this started happening after a system (Windows) crash or an unexpected eclipse shutdown, the problem may be due to a change in the compatibility mode of eclipse.exe. When the system or eclipse crashed, Windows may have decided to change the compatibility mode of eclipse.exe whether you liked it or not.

Unfortunately, this mode can not be changed through the “compatibility” tab on the file properties. The change has to be made by editing the registry. Look for the two keys:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Persisted
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
Look for any entries for eclipse.exe. I deleted one from each location and this solved the problem for me.

The compatibility information is tied to the file name and is persisted in the registry even if the file itself is deleted or moved. This is why changing the location of the eclipse directory will solve the problem. This also means that reinstalling eclipse in the same location will not fix the problem since the registry entry will still be there.