Eclipse - no Java (JRE) / (JDK) ... no virtual machine
Asked Answered
R

35

285

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:

A Java Runtime Environment (JRE) or Java Development kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: C:\eclipse\jre\javaw.exe javaw.exe in your current PATH

I've just done a fresh install of both the JDK and the SDK.

I have Windows 7 (x64).

What's up with this? How do I fix it?

I can't run any of the ipconfig / tracert / or ping.

Retrogress answered 8/1, 2010 at 20:14 Comment(8)
Java Runtime Environment is JRE not SDK...Trompe
Install a JRE - this gives a javaw.exe in your path. JDK's doesn't.Fornax
@Carlos, each JDK brings a private JRE.Fornax
@Thorbjørn: and what is the point? I know that and also that JDK also brings a public JRE. I wrote that "Java Runtime Environment is not SDK" but you have to read the original post (before being edited on January 11th) to understand why I wrote it: "A java Runtime Environment (SDK) or..."Trompe
If you have recently installed JDK in another path after you have installed Eclipse then you may face this issue. This is because the eclipse hard code the JDK path in eclipse.ini when it is setup for the first time. Just change the correct JDK path in eclipse.ini. That should solve this error.Conover
Navigate to C:\Program Files\Java\jreX\bin and copy javaw.exe to C:\Program Files\sts-bundle\sts-X.X.X.RELEASE. If there is no javaw.exe in the bin folder, install Java JRE.Rhizopod
I encountered this issue running Eclipse Keplerx86 on W8.1. Because I'm tidy I just did not want to copy the jre folder inside the eclipse directory, I managed to launch eclipse after reinstalling all jre and making sure paths to java instances did not contain any space. Then I edited the eclipse.ini file (in eclipse root directory) and updated the argument openfile -vm "C\:tools\java\..." path. »Like shown here«. ~I hope it will help and save headaches~Styles
I installed another JRE after creating the eclipse woekspace, so I created a new workspace and it detected the new JREConduplicate
C
224

Eclipse will by default try to launch with the default "java.exe" (the first one referenced by your PATH)

Three things to remember:

  • "Installing" a JRE or a JDK can be as simple as unzipping or copying it from another computer: there is no special installation steps, and you can have as many different JVM versions (1.4, 5.0, 6.0...) as you want, "installed" (copied) almost anywhere on your disk.
  • I would recommend to always run Eclipse with the lastest JRE possible (to benefit from the latest hotspot evolutions). You can:
  • The JVM you will reference within your Eclipse session is not always the one used for launching Eclipse because:
    • You only need a JRE to launch Eclipse, but once Eclipse launched, you should register a JDK for your projects (especially for Java sources and debugging purposes, also in theory for compilation but Eclipse has its own Java compiler) Note: You could register just a JRE within Eclipse because it is enough to run your program, but again a JDK will allow for more operations.
    • Even though the default registered Java in Eclipse is the one used to launch the session, you can want to register an older SDK (including a non-Sun one) in order to run/debug your programs with a JRE similar to the one which will actually be used in production.

Installed JREs


June 2012, jmbertucci comments:

I'm running Windows 7 64-bit and I had the 32-bit JRE installed. I downloaded Eclipse 64-bit which looks for a 64-bit JRE. Because I didn't have the 64-bit JRE it threw the error, which makes sense.

I went to the Java manual install page (which was not as directly accessible as you'd like) and installed the 64-bit version. See "Java Downloads for All Operating Systems". That was all I needed.


April 2016: Steve Mayne adds in the comments:

I had to edit the eclipse.ini file to reference the correct Java path - Eclipse doesn't use the environment PATH at all when there is a value in eclipse.ini.

Cartilage answered 16/5, 2010 at 13:6 Comment(9)
This question/answer is slightly old but I was running into this issue so I'll post my notes. I'm running Win7 64bit and I had the 32bit JRE installed. I downloaded Eclipse 64bit which looks for a 64bit JRE. Because I didn't have the 64bit JRE it threw the error, which makes sense. I went to the Java manual install page (which was not as directly accessible as you'd like) and installed the 64bit version. java.com/en/download/manual.jsp That was all I needed.Further
@Nuktu: I have added jmbertucci's comment to the answerCartilage
@jmbertucci: thank you for your notes. I have added them to the answer for more visibility.Cartilage
@Further you should also have been able to use a 32-bit Eclipse.Fornax
I had the same problem and installing 64bit Java solved the problem.Ssm
If nothing works, just delete your eclipse and reinstall it. Doing so worked for me.Panicle
editing the ini file did it for me. It was looking in the wrong folderSalto
@Cartilage I had to edit the eclipse.ini file to reference the correct java path - Eclipse doesn't use the environment PATH at all when there is a value in eclipse.iniHemlock
@SteveMayne Interesting, thank you. I have included your comment in the answer for more visibility.Cartilage
B
141

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

Replacing javaw.exe in Eclipse Folder

Baedeker answered 22/1, 2013 at 17:35 Comment(5)
I was searching for a simple solution as this answer but it didn't work for me, in case someone has a similar situation, changing the vm directory in the eclipse.ini file might help.Kef
Didn't work for me, gave me Error: opening registry key 'Software\Javasoft\Java Runtime Environment'. I had to copy the whole jre7 (in my case) folder into the Eclipse directory, and rename it jre. Then it worked.Shirl
For somebody fails, try to copy the jre folder to the eclipse folder.Intimidate
@NohaKareem your advice was the closest for me. Unfortunately, my 'jre' folder contained only 'lib', so copying over the Java 'jdk' folder (although larger at 350MB, but had an internal 'bin' folder) and renaming it 'jre' worked. Thanks.Jessalin
Having both 32 and 64 bit java installed but 32bit java in path, trying to open a 64bit eclipse will fail, putting the 64bit javaw file next to exclipse makes it work.Excitant
F
83

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.

Finial answered 8/1, 2010 at 21:48 Comment(5)
It didn't work :) the data of the environment name: Path --- value: C:\Program Files (x86)\Java; C:\Program Files (x86)\Java\jdk1.6.0_14\binRetrogress
Paths with spaces needs to be enclosed in quotes.Finial
my path was configured perfectly configured before, Borland compiler edited the path field and replace the java path with its own path, now its Fixed, thnks!!!Hurry
@Finial Actually, no need to enclose paths in quotes when configuring PATH environment variables on Windows. Just delimiting them with semicolon (;) is enough.Shafer
this is the answer that solves it. after a couple of hours digging through, to those who have the same problem, what you need is: 1) make sure everything is 64-bit. Should automatically install in "program files", NOT "program files(x86)". 2) Write the -VM to the bin folder that the other answers have. 3) Set the path as this guy said. Nothing will ever happen if you cannot run java from the command line. 4) rejoiceStockwell
G
36

Open up Windows' System Properties from the control panel and hunt down the environment variables section:

  • Add a JAVA_HOME entry pointing to the directory where the JDK is installed (e.g. C:\Program Files\Java\jre6)
  • Find the Path entry and add the following onto the end ;%JAVA_HOME%\bin
  • OK the changes
  • Restart eclipse so that it is aware of the new environment

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.

Granulite answered 8/1, 2010 at 21:15 Comment(1)
When I added name:JAVA_HOME value: "C:\Program Files (x86)\Java\jdk1.6.0_14;%JAVA_HOME%\bin" I still get the same errorRetrogress
A
24

If you download the 64 bit version of Eclipse; it will look for the 64 bit version of JRE. If you download the 32 bit version of Eclipse; it will look for the 32 bit version of JRE

What I did was to install the both the 32 and 64 bit version of JRE. You can get that from the SUN Oracle site. The JAVA site seems to automatically install the 32 bit version of Java. I guess that's because of the web browser.

Aronoff answered 10/11, 2010 at 20:47 Comment(3)
As ladookie said the problem most likely was the browser running bad code on Java's web site and getting the wrong version of JAVA...Retrogress
speedbaron is completely right here. If you're modifying your environmental variable PATH, make sure you put the path of the correct version. My Windows 7 64-bit system had a 32-bit JRE installed (don't know why), so I installed the 64-bit version and added to PATH the new directory. It seems to work well now.Selaginella
This was my problem. Note that windows installs 64 bit to C:\Program Files\Java and 32 bit to C:\Program Files (x86)\Java.Cite
R
10

It turned out that all I needed to do was change the 'path' to:

"C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; C:\Program Files (x86)\Java; C:\Program Files (x86)\Java\jdk1.6.0_14\bin"

that did it :)

Retrogress answered 12/1, 2010 at 15:40 Comment(1)
BTW, you should use jdk1.6.0_16 or later. Using jdk 1.6.0_14 you cannot use breakpoints correctly in Eclipse: bugs.eclipse.org/bugs/show_bug.cgi?id=279137Sphinx
J
9

I have windows 7 64-bit, and I had this same problem with eclipse. To get it to work, I had to use internet explorer (64-bit version) to download java. This was the only way to get java to install a 64-bit version. When I used firefox to install java, it automatically installed a 32-bit version (so idiotic!). And The Eclipse 64-bit version wouldn't detect the java 32-bit version.

Juli answered 15/11, 2010 at 1:28 Comment(1)
I don't have the problem anymore - but this seems like a good solution and makes sense - it would be interesting to test this with other 64bit browsers...Retrogress
K
7

Solution in a nutshell:

Right-click on My Computer, click properties, then advanced system settings, a System properties window will popup, under advanced tab, choose environment variables, Environment variables window will popup, under the System variables section , look for PATH variable, and edit the value, changing it (the version; jre6,jre7, etc) to whatever jre you're using, e.g for mine: C:\Program Files\Java\jre7\bin

Kidderminster answered 1/12, 2012 at 8:55 Comment(0)
I
7

Do not rely on the windows path variable because it gets changed in nearly every update. E.g. a chrome (32bit on a 64 bit machine) java update replaces the systemwide 64 bit JVM by a 32 bit JVM. Note also that this entry has to be the last one in the eclipse.ini, otherwise it does not work,And - as otherwise stated - the JAVA_HOME variable is NOT evaluated by eclipse.exe.

even if your has JAVA_HOME and Path configured valid,their may has this problem,so the most simple way to do is open your eclipse.ini in your eclipse installtion folder

-vm

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

replace C:\Program Files\Java\jdk1.7.0_71\bin\javaw.exe with your jdk or jre `s path

Isleana answered 16/12, 2014 at 3:53 Comment(2)
I vote for this answer to be the correct one. Do not rely on the windows path variable because it gets changed in nearly every update. E.g. a chrome (32bit on a 64 bit machine) java update replaces the systemwide 64 bit JVM by a 32 bit JVM. Note also that this entry has to be the last one in the eclipse.ini, otherwise it does not work. And - as otherwise stated - the JAVA_HOME variable is NOT evaluated by eclipse.exe. Please edit your answer accordingly.Ballade
This is the best answer, since it directly resolves the actual problem. Eclipse is looking for a path per a specific parameter, and that value is wrong... so correcting the value fixes the issue.Cornu
O
6

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.

Outset answered 1/2, 2011 at 6:59 Comment(0)
P
6

Don't worry i was also ruined by this error and fatal and when i got it i was so frustrate even i was giving to leave an android programming, but i got it, Simply first of all copy this code and paste in your system variable Under path ...

C:\Program Files;C:\Winnt;C:\Winnt\System32;C:\Program Files\Java\jre6\bin\javaw.exe

Now copy the "jre" folder from your path like i have have "jre" under this path

            C:\Program Files\Java

and paste it in your eclipse folder means where your eclipse.exe file is placed. like i have my eclipse set up in this location

    F:\Softwares\LANGUAGES SOFTEARE\Android Setup\eclipse

So inside the eclipse Folder paste the "jre" FOLDER . If you have "jre6" then rename it as "jre"....and run your eclipse you will got the solution...

   //<<<<<<<<<<<<<<----------------------------->>>>>>>>>>>>>>>>>>>                 

OTHER SOLUTION: 2

If the problem could't solve with the above steps, then follow these steps

  1. Copy the folder "jre" from your Java path like C:\Program Files\Java\jre6* etc, and paste it in your eclipse directory(Where is your eclipse available)
  2. Go to eclipse.ini file , open it up.
  3. Change the directory of your javaw.exe file like

-vmF:\Softwares\LANGUAGES SOFTEARE\Android Setup\eclipse Indigo version 32 Bit\jre\bin/javaw.exe

Now this time when you will start eclipse it will search for javaw.exe, so it will search the path in the eclipse.ini, as it is now in the same folder so, it will start the javaw.exe and it will start working.

If You still have any query you can ask it again, just go on my profile and find out my email id. because i love stack overflow forum, and it made me a programmer.*

Preciado answered 30/12, 2012 at 9:45 Comment(0)
J
5

Edited my eclipse.ini file to update the newly updated JDK. Previously I had jdk1.7.0_09 and updated now to jdk1.7.0_80 and eclipse threw this error.

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: C:/Program Files/Java/jdk1.7.0_09/bin/javaw

After updating eclipse.ini from,

-vm
C:/Program Files/Java/jdk1.7.0_09/bin/javaw

to

-vm
C:/Program Files/Java/jdk1.7.0_80/bin/javaw

Eclipse works fine.

Journeyman answered 31/7, 2015 at 11:33 Comment(1)
This is the solution that worked for me - thanks Lucky. Eclipse loads the JRE referenced in the ini file, so the accepted answer is incorrect in suggesting it looks at the env PATH.Hemlock
P
3

make a batch file in the eclipse folder and write in it :

eclipse -vm C:\Sun\SDK\jdk\jre\bin\javaw.exe

see http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F

Pocket answered 17/12, 2011 at 7:21 Comment(0)
P
3

if after adding the C:\Program Files\Java\jdk1.8.0_92\bin in PATH variable in environment variables the eclipse gave the same error

check eclipse configuration settings file that found in eclipse folder, you must see the same jdk path you have in C:\program Files

enter image description here

I hope it help.

Pesthouse answered 19/8, 2016 at 12:12 Comment(0)
A
2

When I had such problem, in my case I had x64 JDK + JRE installed with x86 Eclipse. So installing of x86 JDK + JRE solved my problem :) Also I created jre folder in eclipse folder and copied bin folder from my local path C:\Program Files (x86)\Java\jre7 to ..\eclipse\jre\.

Allomerism answered 14/3, 2013 at 8:39 Comment(0)
M
2
  • 64-bit OS--> You need: 64-bit Java and 64-bit Eclipse
  • 32-bit OS--> You need: 32-bit Java and 32-bit Eclipse

if you update your java version with default update in your 64 bit computer (and you have 32 bit browser), java will install 32 bit version. You should find 64 bit java version and install it.

Magician answered 22/4, 2014 at 14:34 Comment(0)
M
1

Try setting your JAVA_HOME to the correct folder. Google for setting environment variables in Windows.

Moreira answered 8/1, 2010 at 20:17 Comment(4)
I followed these instructions: wso2.org/project/wsas/java/2.0-beta/docs/setting-java-home.html but to no availRetrogress
I hate to say it...but have you restarted?Moreira
Restarting is not necessary to install Java.Fornax
neither is JAVA_HOME necessary. It is the PATH which is used to find the javaw.exe. (JAVA_HOME is used by some other applications like ant, so it's not wrong setting it anyway)Trompe
C
1

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

Carioca answered 11/1, 2010 at 15:48 Comment(0)
S
1

There is an easier way to do that. Just run cmd x64. Type cmd x64 to search bar in start menu ant you will find it :) Or alternatively, you should set path to program files (x86) ... For example C:\Program Files (x86)\Java\jre6

Stadium answered 30/9, 2010 at 0:6 Comment(0)
V
1

Just Add the JRE PATH FOR Ex: C:\Program Files\Java\jre5\bin in the environmental variable Put ";" in between every path. Then click the eclipse.exe It will work.....

Vitellin answered 8/1, 2011 at 17:44 Comment(0)
G
1

The reason you get this error is because eclipse needs a JRE to launch, which it can't find. The first place it searches is the current directory, then the eclipse.ini file and then finally the system path. So if the it can't find the correct jvm(bit versions are different) through any of these three places, it cribs

The recommended way is to edit the eclipse.ini file and tell eclipse where exactly to look for the vm/jre, by including this line in the file:

-vm
[path to your java.exe] (which is generally under "C:\Program Files\Java\jre7\bin")

P.S. To edit the eclipse.ini, you may need to move the it, edit and then paste it back

Source:- wiki

Gressorial answered 10/3, 2014 at 3:31 Comment(0)
I
1

First of all thanks to YouYou for his solution! I tried answer by YouYou (https://mcmap.net/q/57049/-eclipse-no-java-jre-jdk-no-virtual-machine). Initially, it did not work for me. Following are the steps that I needed to take to make it work:

  1. Initially, I did not have Java installed on my new machine. So, I had to install that (downloaded from: http://java.com/en/download/manual.jsp).
  2. I am running 64-bit OS. But, while downloading, I got the message which could help me in choosing which version of Java to download: Choose the 32-bit download to use with a 32-bit browser. Hence, I downloaded 32-bit version.
  3. Then, I followed the procedure mentioned in https://mcmap.net/q/57049/-eclipse-no-java-jre-jdk-no-virtual-machine, hoping to get the solution.
  4. I got some other error: Java was started but returned exit code=13
  5. Then, I installed 64-bit version of Java.
  6. Copied javaw.exe from that version.

...And Eclipse started working!!! Yaay!

Indolence answered 22/10, 2014 at 16:9 Comment(0)
D
1

Well this answer is to those who tried all of them others an still no luck, May this be Android studio or Eclipse i usually do this when everything else fails.

  1. Find your Android sdk folder and open the android.bat file with a text editor
  2. you will find some commands like these in the start of the file,

set java_exe=

call lib\find_java.bat

if not defined java_exe goto :EOF

  1. Change them to

    set java_exe= <the path to your java.exe file(can be found inside your jdk folder/bin directory)>

  2. find the lines

rem Set SWT.Jar path based on current architecture (x86 or x86_64) for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a

  1. Replace it with set swt_path=<the path to your respective swt.jar file, for x86 it is at sdk\tools\lib\x86 and for x64 at sdk\tools\lib\x86_64>
  2. Save and close the file and now you are good to go..
Dissection answered 18/11, 2014 at 6:41 Comment(0)
S
1

I have run into this problem too. My case is as following:

enter image description here enter image description here

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);
#>


<#

#https://mcmap.net/q/57353/-how-do-i-conditionally-add-a-class-with-add-type-typedefinition-if-it-isn-39-t-added-already

#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:
https://mcmap.net/q/57354/-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
Secretary answered 26/12, 2017 at 9:17 Comment(0)
B
0

Check Window > Preferences > Java > Installed JREs. Make sure there's something there; if there isn't, add one.

Did you recently update your JDK?

Backcross answered 8/1, 2010 at 20:21 Comment(1)
Yes I tried to add the android add-on. But no (like Topher Fangio said,) I can't start Eclipse now.Retrogress
H
0

The JDK does not install a JVM in the default path.

Unless you need external tools to run like ant, the non-JDK is enough for Eclipse to run. The easiest way to install such a JVM is to go to http://java.com and let it install whatever it want to install.

Then double-click the Eclipse binary again.

Heritable answered 8/1, 2010 at 21:6 Comment(2)
I re-installed it (it even asked if i wanted to reinstall it) with no avail. ( I did both the Google Chrome plugin 14 - or something like that && the Firefox )Retrogress
You went to java.com? Not javasoft.com?Fornax
T
0

set JAVA_HOME variable and ad JAVA_HOME/bin to evnrionment path variable.

Trillbee answered 8/1, 2010 at 21:22 Comment(3)
like this: "C:\Program Files (x86)\Java; C:\Program Files (x86)\Java\jdk1.6.0_14\bin" ? - it still didn't work :)Retrogress
Referencing JAVA_HOME in the path variable requires embedding it: %JAVA_HOME%\binBallade
For me (Windows 10 64 bit + Eclipse 4.10) the trick was to add, in addition to the JAVA_HOME environment variable, the JRE_HOME variable, which was set to the location of the javaw.exe location (which is probably always the bin folder of the JDK which is installed).Outwash
T
0

I had the same issue (Windows 7 x64, 64bit JDK, 32bit Eclipse), and I found 2 solutions:

  • Install the 64 bit version of Eclipse (found by clicking the "Development Builds" tab on the downloads page.)
  • Install the 32bit version of the JDK.
Tristan answered 21/4, 2010 at 1:58 Comment(2)
See but you were using Windows 7 x86 where I was using x64 --- as others have stated this problem may have been a glych on SUN's part in their programing of how their web page 'detects the version' (i.e. x64 or x86) you should useRetrogress
Correction, I was using Windows 7 x64Tristan
R
0

I had the same problem. The easy way, for me to fix it was to install both the JRE and the eclipse as x86 or x64. When their bit type did not match, eclipse could not find it. So, if it is not a big deal for you to uninstall and reinstall in order to make them match, I would do that.

I ended up installing: Java Runtime Environment 1.7.0.3 (64-bit) and Eclipse Indigo (3.7) (64-bit)

Then it just works.

Robot answered 29/2, 2012 at 16:9 Comment(0)
P
0

When I copied only javaw, the second error occured, there is not a java.dll file, when I copied it too, eclipse did not start, what I did was that I copied whole jdk folder to eclipse folder and renamed id to jre. Problem solved.

Pulsifer answered 18/3, 2015 at 13:21 Comment(0)
I
0

One problem is the conflict between the Eclipse-64bit version and our Java installation being 32bit version. This doesn't get solved easily because the Java installation page doesn't give the option for 64bit - it assumes 32bit and downloads and installs the 32bit version. To overcome this issue, please follow the following steps:

  1. Download the 64bit version by going to Java SE Runtime Environment 7 (this link gives us the option to download a 64bit version of Java). Download and install this.
  2. Now, trying to install Eclipse will still throw an error. So, we copy the jre7 folder from C:/program files/Java/ and copy it in our Eclipse installation folder.
  3. Now, we rename it to jre.

Install Eclipse.

--launcher.appendVmargs -vm C:\Program Files\Java\jdk1.7.0_79\jre\bin\javaw.exe -vmargs

Insociable answered 11/8, 2015 at 4:0 Comment(0)
B
0

First go to computer then properties then advanced system settings then advanced

(3rd menu)

and then click environment variables button at the bottom.

To path in environment variables you add:

C:\Program Files\Java\jdk1.8.0_102\bin\;C:\Program Files\Java\jdk1.8.0_102\lib\; 

and the error will go away. This is the best one.

The other way is to copy the jre folder (C:\Program Files\Java\jre1.8.0_102) to

E:\eclipse-jee-indigo-SR2-win32\eclipse

folder. Then the error will go away.

Brandabrandais answered 30/8, 2016 at 10:36 Comment(0)
B
0

I have a SIMPLE solution to this problem. I solved it by changing vm path in eclipse.ini file to latest jre path.

I follwed this link : https://youtu.be/lU_eb5Ki1kY

Barely answered 25/5, 2020 at 17:55 Comment(0)
M
0

Go to Eclipse -->Windows--->Preferences then go to Installed JRE then in click on add then add the new JDK path (path where jdk installed in your machine)

then click Ok

It should mapped to eclipse and work.

Note- Only latest JDK you mapped will be shown as ticked in installed JRE with Type as Standard and name as default.

Thanks.

Mogerly answered 16/11, 2022 at 9:56 Comment(0)
B
-1

Just download the Java Runtime Environment (JRE). That worked for me!

Brion answered 4/7, 2014 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.