94

This doesn't work -vm %JAVA_HOME%/bin/javaw.exe

How can I replace %JAVA_HOME% with full path on Windows 8 when path contains space ("Program Files" directory)

Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
user310291
  • 36,946
  • 82
  • 271
  • 487
  • http://www.onkarjoshi.com/blog/84/configuring-eclipse-to-use-a-jdk-at-a-location-with-spaces-in-it/ You can obtain path without spaces with windows command line. – Schabowy Apr 19 '14 at 19:18
  • Why do you need to specify -vm argument. Leave ini file alone and set JAVA_HOME environment variable instead. – JamesB Apr 19 '14 at 19:33
  • Have you tried `%JAVA_HOME%\bin\javaw.exe` with backward slash? Have your set the `JAVA_HOME` enviroment system property? – Braj Apr 19 '14 at 19:37
  • @Braj yes I did set the environment variable in computer advanced properties – user310291 Apr 19 '14 at 20:43
  • Look at my answer you don't need to set the environment variable. Its working fine for me. – Braj Apr 19 '14 at 20:44

15 Answers15

235

Have you tried it. Don't put everything in single line.

-vm
C:\Program Files\Java\jdk1.6.0_07\bin\javaw.exe

Need to put the folder that contains the javaw or java executable. Under Ubuntu 18 with eclipse 4.7.1 I was able to get it to run with:

-vm
/usr/lib/jvm/java-8-openjdk-amd64/bin
-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.500.v20170531-1133
-vmargs
-Xmx2G
-Xms200m
-XX:MaxPermSize=384m

If it doesn't work then please confirm you have added above lines before -vmargs in eclipse.ini.

Sergei Krivonos
  • 4,217
  • 3
  • 39
  • 54
Braj
  • 46,415
  • 5
  • 60
  • 76
  • 1
    By the way it's eclipse I downloaded from android dev site – user310291 Apr 20 '14 at 05:16
  • 6
    I know this topic is old, but I had the same problem, in which none of the solutions mentioned here had worked - but I *DID* eventually solve it. First, note that using the Windows Environment Variable "JAVA_HOME" is the preferred method, but -vm will work as well. The cause / solution was: I was using Eclipse 64-bit version, but pointing to a 32-bit JRE - after installing, then pointing to, the 64-bit JRE, all worked well. Thought I'd share this. – NYCBilly Feb 12 '16 at 03:11
  • Thanks NYCBilly. It is very important to check the version (32-bit or 64 bit). – Mohamed El-Beltagy Mar 24 '16 at 19:22
  • 2
    use forward slashes in the eclipse.ini, in which case (even on windows) you do not have to escape the path ie C:/Program Files/Java/jdk1.6.0_07/bin – johnm May 10 '16 at 11:24
  • After added the above two lines, it worked. My java home configured as 1.6 for other purposes but i wanted to use eclipse neon IDE, so about trick worked. – Janath Sep 29 '17 at 02:36
  • simply best answer. – Mayur Patil Apr 05 '18 at 04:02
59

Add the entry of vm above the vm args else it will not work..! i.e `

    -vm
    C:\Program Files\Java\jdk1.7.0_75\bin\javaw.exe
    --launcher.appendVmargs
    -vmargs
    -Dosgi.requiredJavaVersion=1.6
    -Xms40m
    -Xmx512m
Sreedhar GS
  • 2,694
  • 1
  • 24
  • 26
30

tl;dr

The -vm option must occur after the other Eclipse-specific options (such as -product, --launcher.*, etc), but before the -vmargs option, since everything after -vmargs is passed directly to the JVM.
Add the -vm option on its own line and the path to your JDK executable on the following line; e.g.

-vm
C:\Program Files\Java\jdk1.8.0_161\bin\

Details

Notes

  • The path is on a new line below the -vm option
  • There is no need to escape any characters or use slashes (back-slashes are fine)
  • The path points to the bin directory, not to javaw.exe

Gotcha JAVA_HOME

When you don't specify a virtual machine in your eclipse.ini file, you may think that the JAVA_HOME environment variable is used, but this is not the case!
From FAQ_How_do_I_run_Eclipse#Find_the_JVM

Eclipse DOES NOT consult the JAVA_HOME environment variable.

Instead the Windows search path will be scanned.

Recommendation
You may think it is a good idea to use the search path, because it is flexible.
While this is true, it also has the downside that the search path may be altered by installing or updating programs.
Thus, I recommend to use the explicit setting in the eclipse.ini file.

Finding a VM

The reason why you should specify the bin directory and not the javaw.exe (as proposed by many other answers), is that the launcher can then dynamically choose which is the best way to start the JVM. See details of the launcher process for all details:

We look in that directory for: (1) a default.ee file, (2) a java launcher or (3) the jvm shared library.

Verfication

You can verify which VM is used by your running eclipse instance in the Configuration dialogue.
In eclipse Oxygen go to Help - About Eclipse - Installation Details - Configuration

You will see which VM path eclipse has chosen, e.g.:

eclipse.vm=C:\Program Files\Java\jdk1.8.0_161\bin\..\jre\bin\server\jvm.dll
TmTron
  • 17,012
  • 10
  • 94
  • 142
  • 2
    tl;dr is quite incorrect. `-vm` should **not** be at the top of your `eclipse.ini` file. Per [this documentation](https://wiki.eclipse.org/Eclipse.ini), "The -vm option must occur after the other Eclipse-specific options (such as -product, --launcher.*, etc), but before the -vmargs option, since everything after -vmargs is passed directly to the JVM." Also has to point to executable, not directory. – Jeff Axelrod Mar 06 '20 at 23:59
  • Edited answer per above comment. – Jeff Axelrod Mar 07 '20 at 01:03
  • 1
    @JeffAxelrod thanks for the edit - I was not aware of that – TmTron Mar 07 '20 at 07:16
10

I was facing the same issue but was unable to solve, until I try this:

  1. Please make sure you put -vm
  2. Then press Enter
  3. And then paste C:\Program Files\Java\jdk1.6.0_07\bin\javaw.exe
nicolallias
  • 1,055
  • 2
  • 22
  • 51
  • 1
    Thank you! Who'd have thunk "press ENTER is important"!? I kept adding -vm to the ini file, it couldn't find it. Once I inserted a newline, it worked!! It didn't matter if we specified javaw.exe or not. – svaratech Nov 16 '20 at 13:37
6

if you are using mac, proceed with following steps:

  1. Move to following directory:

    /sts-bundle/STS.app/Contents/Eclipse
    
  2. Add the java home explicitly in STS.ini file:

    -vm
    /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin
    -vmargs
    

Make sure not to add all the statements in single line

KayV
  • 12,987
  • 11
  • 98
  • 148
4

Solution in:How do I set the eclipse.ini -vm option?

-vm C:\\bin

 -vm
C:\<java_path>\bin

Must be the first thing in eclipse.ini

chindo
  • 61
  • 5
4

All above answers didn't work for me. My Eclipse mars is x64 but I need to set registry dll to x86 for another software.

At the end I put -vm argument at the end of shortcut and this did the trick.

D:\mars\eclipse\eclipse.exe -vm "C:\Program Files\Java\jre7\bin\server\jvm.dll"

According to this doc jvm.dll also work for some cases.

Davut Gürbüz
  • 5,526
  • 4
  • 47
  • 83
  • 1
    This one works for me for spring tool suite eclipse ..Thanks – vinod Mar 01 '17 at 09:44
  • Nothing else worked because the VM argument in the shortcut gets picked up first. I removed `-vm` in my shortcut then `-vm` was picked up from `SpringToolSuite4.ini`. – Philip Rego Aug 19 '21 at 17:34
2

Even if your %JAVA_HOME% contains spaces, you can directly put entire string over there.

-vm
C:\Program Files (x86)\Java\jdk1.8.0_162\bin

Also, you don't have to specify javaw.exe in the path, just mention it till bin it will find javaw.exe in bin folder by itself. Just keep one thing in mind that the jdk version you provide should match with the eclipse version you are using.

If you are using a 64 bit java then download 64 bit Eclipse. If you are using a 32 bit java then download 32 bit Eclipse.

Shubham Arya
  • 585
  • 5
  • 18
1

Windows-vm "C:\Program Files\Java\jdk1.6.0_07\jre\bin\javaw.exe"

Grigori Melnik
  • 4,067
  • 2
  • 34
  • 40
Robert
  • 11
  • 1
1

I have Windows 8.1 and my JDK under "Program Files" as well. What worked for me was replacing the name of the folder by the 8-digit internal MS-DOS name.

-vm
C:/PROGRA~1/Java/jdk1.8.0_40/bin/javaw.exe

I realized what was going on after running this in cmd.exe

CD \
DIR P* /X

It returned...

<DIR>          PROGRA~1     Program Files
<DIR>          PROGRA~2     Program Files (x86)

So we can find out how to use a path containing spaces

derloopkat
  • 6,232
  • 16
  • 38
  • 45
0

Try to escape the space with back slash.. Like

C:\program\folder\ \name\java\jdk\bin

BlackPOP
  • 5,657
  • 2
  • 33
  • 49
0

Go to C drive root in cmd Type dir /x This will list down the directories name with ~.use that instead of Program Files in your jdk path

now30
  • 40
  • 6
0

Sometimes spaces in path create a problem. You can add e.g. -vm C:\progra~1\Java\jre1.8.0_112\bin\javaw.exe

Rajesh Renke
  • 87
  • 1
  • 1
  • 7
-3

-vm C:\Program Files\Java\jdk1.6.0_07\bin\javaw.exe

-9

Reinstall java and choose a destination folder without a space

Joe
  • 1