我正在尝试让Eclipse v3.5 (Galileo)在我的计算机上重新运行-我以前运行过,没有问题,但现在我一直得到这个错误:

要运行Eclipse,必须提供Java运行时环境(JRE)或Java开发工具包(JDK)。在搜索以下位置后没有发现Java虚拟机: C: \ eclipse \ jre \ javaw.exe javaw.exe在当前路径

我刚刚重新安装了JDK和SDK。

我用的是Windows 7 (x64)。

这是怎么回事?我该怎么解决呢?

我不能运行任何ipconfig / tracert /或ping。


当前回答

一个问题是eclipse -64位版本和我们的Java安装为32位版本之间的冲突。这个问题不容易解决,因为Java安装页面没有提供64位的选项——它假设是32位,然后下载并安装32位的版本。要解决此问题,请遵循以下步骤:

通过转到Java SE运行时环境7下载64bit版本(此链接为我们提供了下载64bit版本Java的选项)。下载并安装。 现在,尝试安装Eclipse仍然会抛出一个错误。因此,我们从C:/program files/Java/复制jre7文件夹,并将其复制到Eclipse安装文件夹中。 现在,我们将其重命名为jre。

安装Eclipse。

——launcher.appendVmargs 虚拟机 C:\Program Files\Java\ jdk1.7.0_79 \ jre \ bin \ javaw.exe —vmargs

其他回答

不要依赖windows path变量,因为它几乎在每次更新中都会更改。例如,chrome(64位机器上的32位)java更新将全系统64位JVM替换为32位JVM。还要注意的是,这个条目必须是eclipse.ini中的最后一个条目,否则它将不起作用,并且-如前所述- eclipse.exe不会计算JAVA_HOME变量。

即使你的JAVA_HOME和路径配置有效,他们可能有这个问题,所以 最简单的方法是打开eclipse安装文件夹中的eclipse.ini

虚拟机 C:\Program Files\Java\ jdk1.7.0_71 \ bin \ javaw.exe

将C:\Program Files\Java\ jdk1.7.0_71\bin\javaw.exe替换为jdk或jre的路径

在eclipse.ini文件中,需要更新VM的路径,使其指向机器上安装javaw.exe的同一位置。

我也遇到过这个问题。我的案例如下:

在文本:

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

我发现他们的注册表值Path的类型是不同的,所以我用下面的命令检查路径是否有效:

C:\Users\ssfang> where node java
C:\ProgramFiles\nodejs\node.exe
INFO: Could not find "java".

因此,我通过以下命令(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

但是,在当前流程中,它不能将这些更改传播到其他正在运行的流程。

但是,如果直接在“注册表编辑器”中修改用户环境变量,

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.

详细信息请参见如何将环境变量传播到系统

在这里,我给出了一个powershell脚本来完成它:

# 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

当我遇到这样的问题时,在我的情况下,我用x86 Eclipse安装了x64 JDK + JRE。所以安装x86 JDK + JRE解决了我的问题:)我还在eclipse文件夹中创建了JRE文件夹,并将bin文件夹从我的本地路径C:\Program Files (x86)\Java\jre7复制到..\eclipse\ JRE \。

我有一个简单的解决这个问题的方法。我通过将eclipse.ini文件中的vm路径更改为最新的jre路径来解决这个问题。

我点击了这个链接:https://youtu.be/lU_eb5Ki1kY