I am trying to get Eclipse v3.5 (Galileo) to re-run on my computer - I have run it before with no problems, but now I keep getting this error:
All the other answers about setting only the JAVA_HOME
are not entirely right. Eclipse does namely not consult the JAVA_HOME. Look closer at the error message:
...in your current PATH
It literally said PATH
, not JAVA_HOME
.
Rightclick My Computer and choose Properties (or press Winkey+Pause), go to the tab Advanced, click the button Environment Variables, in the System Variables list at the bottom select Path
(no, not Classpath
), click Edit and add ;c:\path\to\jdk\bin
to the end of the value.
Alternatively and if not present, you can also add JAVA_HOME
environment variable and make use of it in the PATH
. In the same dialogue click New and add JAVA_HOME
with the value of c:\path\to\jdk
. Then you can add ;%JAVA_HOME%\bin
to end of the value of the Path
setting.
Open up Windows' System Properties from the control panel and hunt down the environment variables section:
Most Java tools will now be able to find your Java installation either by using the JAVA_HOME environment variable or by looking for java.exe / javaw.exe in the Path environment variable.
I have run into this problem too. My case is as following:
In text:
HKEY_CURRENT_USER\Environment
Path REG_SZ %JAVA_HOME%\bin;C:\ProgramFiles\nodejs
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
JAVA_HOME REG_SZ C:\ProgramFiles\Java\jdk
Path REG_EXPAND_SZ C:\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\
WindowsPowerShell\v1.0\;C:\Program Files\Intel\DMIX;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Progra
m Files (x86)\Perforce;C:\ProgramFiles\010 Editor;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\ProgramFiles\
Git\cmd;C:\Program Files (x86)\Skype\Phone\
C:\Users\ssfang> echo %^JAVA_HOME% = "%^JAVA_HOME%" = %%JAVA_HOME%% %JAVA_HOME%
%JAVA_HOME% = "%^JAVA_HOME%" = %C:\ProgramFiles\Java\jdk% C:\ProgramFiles\Java\jdk
I found their types of the registry value Path
are different, so I checked whether the path is valid or not by the following command:
C:\Users\ssfang> where node java
C:\ProgramFiles\nodejs\node.exe
INFO: Could not find "java".
As a result, I reset the local (current user) environment by the following commands (Setx):
C:\Users\ssfang> setx PATH %^JAVA_HOME%\bin;"C:\ProgramFiles\nodejs"
SUCCESS: Specified value was saved.
C:\Users\ssfang> reg query HKEY_CURRENT_USER\Environment /v Path
HKEY_CURRENT_USER\Environment
Path REG_EXPAND_SZ %JAVA_HOME%\bin;C:\ProgramFiles\nodejs
C:\Users\ssfang> where node java
C:\ProgramFiles\nodejs\node.exe
INFO: Could not find "java".
C:\Users\ssfang>echo %PATH%
C:\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Fi
les\Intel\DMIX;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Perforce;C:\ProgramFile
s\010 Editor;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\ProgramFiles\Git\cmd;C:\Program Files (x86)\Skype\
Phone\;%JAVA_HOME%\bin;C:\ProgramFiles\nodejs
But, in the current process, it cannot propagate those changes to other running processes.
However, if you directly modify user environment variables in the Registry Editor,
those modifications to the environment variables do not result in immediate change. For example, if you start another Command Prompt after making the changes, the environment variables will reflect the previous (not the current) values. The changes do not take effect until you log off and then log back on.
To effect these changes without having to log off, broadcast a WM_SETTINGCHANGE message to all windows in the system, so that any interested applications (such as Windows Explorer, Program Manager, Task Manager, Control Panel, and so forth) can perform an update.
See details at How to propagate environment variables to the system
Here, I give a powershell script to do it:
# powershell -ExecutionPolicy ByPass -File
# Standard, inline approach: (i.e. behaviour you'd get when using & in Linux)
# START /B CMD /C CALL "foo.bat" [args [...]]
# powershell -ExecutionPolicy ByPass -WindowStyle Hidden -File myScript.ps1
<#
Add-Type @'
public class CSharp
{
public static void Method(object[] first, object[] second)
{
System.Console.WriteLine("Hello world");
}
}
'@
$a = 1..4;
[string[]]$b = "a","b","c","d";
[CSharp]::Method($a, $b);
#>
<#
#http://stackoverflow.com/questions/16552801/how-do-i-conditionally-add-a-class-with-add-type-typedefinition-if-it-isnt-add
#Problem Add-Type : Cannot add type. The type name 'PInvoke.User32' already exists.
if (-not ("MyClass" -as [type])) {
add-type @"
public class MyClass { }
"@
}
p.s. there's no Remove-Type; see this answer for more on how to best work around this limitation:
http://stackoverflow.com/questions/3369662/can-you-remove-an-add-ed-type-in-powershell-again
I think it will be wanted when debugging.
It is much simpler to close a tab in Console and open new one in PowerShell_ISE.exe or close PowerShell.exe.
Or
Start-Job -ScriptBlock {
param([uri]$url,$OutputDir)
# download and save pages
Invoke-RestMethod $url | Out-File "$OutputDir\$($url.Segments[-1])" -Force
} -ArgumentList $link,$OutputDir
#>
if (-not ([System.Management.Automation.PSTypeName]'PInvoke.Program').Type)
{
$sig=@"
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Collections.Generic;
// The global namespace is the "root" namespace: global::system will always refer to the .NET Framework namespace System.
///P/Invoke (Platform Invoke)
namespace PInvoke
{
public static class User32
{
/// http://www.pinvoke.net/default.aspx/Constants/HWND.html
// public const IntPtr HWND_BROADCAST = new IntPtr(0xffff);
/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms725497(v=vs.85).aspx
/// http://www.pinvoke.net/default.aspx/Constants/WM.html
public const UInt32 WM_SETTINGCHANGE = 0x001A;
// SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) "Environment", SMTO_ABORTIFHUNG, 5000, &dwReturnValue);
/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms644952(v=vs.85).aspx
/// If the function succeeds, the return value is nonzero.
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SendMessageTimeout", SetLastError = true)]
public static extern uint SendMessageTimeout(IntPtr hWnd, uint Msg, int wParam, string lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out int lpdwResult);
}
[Flags]
public enum SendMessageTimeoutFlags : uint
{
SMTO_NORMAL = 0x0,
SMTO_BLOCK = 0x1,
SMTO_ABORTIFHUNG = 0x2,
SMTO_NOTIMEOUTIFNOTHUNG = 0x8,
SMTO_ERRORONEXIT = 0x20
}
public class Program
{
public static void Main(string[] args)
{
//int innerPinvokeResult;
//uint pinvokeResult = User32.SendMessageTimeout(User32.HWND_BROADCAST, User32.WM_SETTINGCHANGE, 0, "Environment", SendMessageTimeoutFlags.SMTO_NORMAL, 1000, out innerPinvokeResult);
Console.WriteLine("Over!!!!!!!!!!!!!!!!!!!!!!!!!");
}
}
}
"@
Add-Type -TypeDefinition $sig
}
## [PInvoke.Program]::Main([IntPtr]::Zero);
$innerPinvokeResult=[int]0
[PInvoke.User32]::SendMessageTimeout([IntPtr]0xffff, [PInvoke.User32]::WM_SETTINGCHANGE, 0, "Environment", [PInvoke.SendMessageTimeoutFlags]::SMTO_NORMAL, 1000, [ref]$innerPinvokeResult);
Setx setx [/s [/u [] [/p []]]] [/m]
/m Specifies to set the variable in the system environment. The default setting is the local environment
In your eclipse.ini
file, you need to update the path to the VM to point to the same location where javaw.exe
is installed on your machine.
I had a co-worker with this exact problem last week. He fixed it by installing the x64 version of Eclipse and the x64 JDK.
Edit: he reused his old workspace after installing the necessary plugins, so that should not be much of an issue
Just copy this file :
c:/Program Files/Java/jre(5,6,7..any version)/bin/javaw.exe
to Eclipse Folder
*note only tested for Windows