1

It is a know problem, when you update Java, JDK or JRE, on Windows Eclipse will likely to fail to start as it points to outdated JDK/JRE folder. Fix is relatively simple, it was discussed and solved on several threads like here or here.

But I found those solutions unsatisfyingly inflexible. This solutions suggest to manually fix path in eclipse.ini to something like:

-vm C:\Program Files\Java\<jdk-version-just-installed>\bin\javaw.exe

This means you have to do it after every update, again and again. If you update JDK frequently, and everyone should to have latest security patches, that makes it very annoying.

I expect that after a smart installation every Java program would just run out of box without any manual step involved; any solution less than that I would not consider satisfactory.

I can think of two ways:

  • using environmental (system) variable like JAVA_HOME. Can eclipse.ini reference environmental variables?

  • using symbolic link pointing to the latest JDK. And if you wonder, yes, Windows with NTFS support symlinks.

Both ways however need some cooperation from the installer, both JAVA_HOME or symlink as to be updated to the new value. Automatically of course, otherwise there would be no reason why to have them in the first place. Please correct me if I am wrong, but JDK/JRE installation on linux does exactly that, provides and updates symlink to latest JDK/JRE. Why not Windows installer?

Is there a hidden parameter, option or a toggle in Java install tool doing that?
If not, is there a better, an alternative installation tool?
Can Eclipse launcher itself find a latest Java?
Is there a better eclipse.ini parameter for that?

Community
  • 1
  • 1
Espinosa
  • 2,132
  • 18
  • 22

3 Answers3

3

The purpose of specifying the VM in either eclipse.ini or on the command line is to isolate it from system updates. For example, in the past it has been a big problem that some programs install their own JVM and include it on the system PATH (Oracle was particularly bad about this). So the entire idea is to isolate Eclipse from those kinds of changes; it should not care what other JVMs you have on your system, it refers to a "known" good one for running Eclipse.

Another alternative is to place a JVM directly under the Eclipse installation directory, in a directory named jre, as documented here. I don't personally ever do that, however; I find it to be unnecessary and cumbersome.

What I do that would probably help you is to not install JVM updates into separate directories with names that reflect the actual update version. Instead, I install JDKs into a consistent place based on the major java version. For example:

/Java/
    /JDK/
        /1.7/
            /bin/
            <etc...>
        /1.8/
            /bin/
            <etc...>

That way, in eclipse.ini (or any other place a need to refer to a particular JVM) I just use /Java/JDK/1.8 and that will continue to work no matter how many updates I install into that location.

E-Riz
  • 28,616
  • 7
  • 83
  • 119
  • I have tried it and you are right, it can be installed like that, and updated too. Anyone attempting this way though be warned; the official Java installer does everything possible to discourage this patterns - many extra manual steps, twice, one for JRE and similar but not same dialogs for JDK; easy to make a mistake and you can start again. Huh. Installers should not be like that. Lousy job Oracle! – Espinosa Apr 02 '17 at 19:04
0

What we do to avoid this problem: We have custom dedicated JDK's for our development environment (for eclipse and for our products), which are not 'attached' to the system. We're using softlinks e.g. ../app/jdk which links to a specific jdk, for intellij we have a ../app/intellij-jdk softlink.

Not sure who to do it in windows, but in linux you download the gzip and extract it, withing messing up your system, like paths, I think for windows you can only download the installer, but it's possible to only extract the actual software from the executable.

slowy
  • 209
  • 1
  • 6
  • I definitively prefer to use system wide installation of Java and to have the latest. I never had Java minor version update issues with Eclipse, IntelliJ, DocFetcher or similar desktop oriented application, actually not even with the major ones. On server front, especially for live environments, that is a bit different story. – Espinosa Apr 02 '17 at 18:59
0

Older Windows JDK installers used to copy java.exe and javaw.exe (and also javavm.dll I think) in c:\windows\system32 to make them available in the default path.

In recent installers, a symbolic link is created for java.exe, javaw.exe and javaws.exe in C:\ProgramData\Oracle\Java\javapath. This means that these executables will point always to the most recent JDK update.

Little Santi
  • 7,940
  • 2
  • 14
  • 40
  • That is an interesting observation, thanks, but unfortunately I need reference to a full JRE/JDK home directory, with all JARs and DLLs. – Espinosa Apr 02 '17 at 18:55