Setting the JDK for the Eclipse IDE

SumitBando commented that the eclipse.ini file has become STS.ini in recent versions of STS. If you’re using Spring’s modified version of eclipse, look for that file instead.

I am a confirmed intelliJ user for Java programming, but I have been dabbling with eclipse recently.  I’m mainly interested in it due to SpringSource’s Tool Suite and also the Scala eclipse plugin.  I’m using the preconfigured sts builds from SpringSource’s website, which includes several plugins including Maven Integration.  These plugins require access to a JDK (as opposed to the JRE) which is not configured by default.  Starting eclipse will launch a warning of the problem:

“The Maven Integration requires that Eclipse be running in a JDK, because a number of Maven core plugins are using jars from the JDK. Please make sure the -vm option in eclipse.ini is pointing to a JDK and verify that Installed JRE’s are also using JDK installs.”

eclipse_ini_warning

This is very good advice, but it is lacking in that it doesn’t explain how to modify the eclipse.ini to accomplish this purpose.  I was surprised at the amount of searching required to find the answer, so I’m posting my findings.

The eclipse.ini file is located in the base eclipse directory.  On linux, you’ll want to specify the complete path to javaw.exe.  Here is a copy of my file (with SpringSource customizations):

-showsplash
com.springsource.sts
–launcher.XXMaxPermSize
256M
-framework
plugins\org.eclipse.osgi_3.4.

3.R34x_v20081215-1030.jar
-vm
C:\Java\jdk1.6.0_13\bin\javaw.exe

-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx768m
-XX:MaxPermSize=256m
Advertisements
This entry was posted in Code and tagged , , , . Bookmark the permalink.

22 Responses to Setting the JDK for the Eclipse IDE

  1. Fletch says:

    Thanks. On windows I put in -vm “%JAVA_HOME%” and it seems to have worked.

  2. Fletch says:

    Wait – I take that back. Doesn’t work. In fact no matter what I do it doesn’t seem to work.

    • Jim says:

      Bummer! The example above worked on my Windows machine. After specifying the full path to javaw.exe, did you still receive the Maven integration warning?

  3. openvn says:

    -to Jim : thank very much.
    -to Fletch : i think you should add -vm option in order like example.I had problem like you,so i try to reorder and it work,if need you can read more here : http://wiki.eclipse.org/Eclipse.ini .good luck to you.

  4. SumitBando says:

    The eclipse.ini file seems to have become STS.ini.

  5. Graphity says:

    Hi. It’s important to say the position of the inserted line must be ABOVE the “-vmargs” line. I have put it right in front and right behind it. But it only worked before it (dunno about far before it)

  6. Sridhar says:

    Thanks for your post. It helped solve the problem. I was using “-vm jdk-path” in the same line, unaware of below rule.

    Each option and each argument to an option must be on its own line.

  7. sheikshavali says:

    Thanks jim for the post and thanks to Graphity for telling the exact position to place the path in eclipse.ini

  8. Ashu Pachauri says:

    I just corrected the problem in STS.ini; the correct order matters.Thanks very much for your useful post.

  9. Gernot says:

    thanks for this post and thanks for all replies

  10. Robert says:

    Good job thanks keep posting…

  11. Alex Potapov says:

    Thanks a lot… very help me

  12. Dave says:

    I needed to add a ‘-‘ before the path to the javaw.exe in STS.ini on my windows 7 machine.

    • Dave says:

      Correction. I think the ‘-‘ just hid the argument. I still got the Maven warning when starting STS.
      I think the real issue was using a 32-bit version of JDK with 64-bit version of STS. I updated Java version, removed ‘-‘ and all seems to be working now

  13. Great post.
    It doesn’t mind spaces in the path also, as in:
    -vm
    C:\Program Files\Java\jdk1.6.0\bin\javaw.exe

  14. Really helful post…..

    thanks a lot

  15. Vempa says:

    Thanks alot for this post and replies..

  16. Katherine says:

    Thanks so much!

    I added a space after -vm instead of hitting enter. Now that I’ve fixed it, everything’s beautiful! (Until I run into the next error. 😀 )

  17. tscharlii says:

    Thanks for the post and replies.

    Putting the -vm line before the -vmargs line in eclipse.ini and following the “Each option and each argument to an option must be on its own line.”-rule resolved the error message for me, too:

    […]
    -vm
    C:\Program Files (x86)\Java\jdk1.6.0_25\bin\javaw.exe
    -vmargs
    […]

  18. sebastian says:

    Version .26
    I solved the problem by specifying the following right after the -vm command

    […]
    -vm
    C:\Program Files\Java\jdk1.6.0_26\jre\bin\client\jvm.dll
    -vmargs
    […]

    No more maven warnings.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s