如何在eclipse的配置文件里指定jdk路径

如题所述

      Eclipse是免费的Java开发集成工具,在启动的时候需要安装并配置JDK,在某些情况下,Eclipse版本过高以及JDK版本过低而导致启动失败,即不卸载原来的JDK也想指定高版本的JDK,此时我们可以对Eclipse的配置文件----eclipse.ini中进行设置。

      工具:Eclipse Neon版本

      JDK: 1.6版本和1.8版本

    在控制面板显示JDK1.6版本信息和JDK1.8版本信息,证明两个JDK都存在


    打开Eclipse安装目录,找到eclipse.ini文件

    打开配置文件,显示结果如下

    -startup
    plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
    --launcher.library
    C:/Users/Administrator.2013-20160723AN/.p2/pool/plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740
    -product
    org.eclipse.epp.package.committers.product
    --launcher.defaultAction
    openFile
    -showsplash
    org.eclipse.platform
    --launcher.appendVmargs
    -vmargs
    -Dosgi.requiredJavaVersion=1.8
    -XX:+UseG1GC
    -XX:+UseStringDeduplication
    -Dosgi.requiredJavaVersion=1.8
    -Xms256m
    -Xmx1024m
    -Declipse.p2.max.threads=10
    -Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
    -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/

    在eclipse.ini配置文件中找到vmargs,并在之前增加-vm参数来指定jdk路径:

    (JDK1.8版本的安装路径:C:\Program Files\Java\jdk1.8.0_20......)

    -vm

    C:\Program Files\Java\jdk1.8.0_20\bin\javaw.exe


    添加之后显示如下:


    更改配置之后,需要重写启动eclipse即可。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-09-28
今天下载了eclipse4.6版本,打开时报Version 1.7.0_45 of the JVM is not suitable for
this product. Version:1.8 or greater is required.,提示jdk版本要1.8以上,如下图:

由于不想直接将环境变量配置的jdk1.7改为jdk1.8,所以单独在eclipse的配置文件里指定jdk来运行eclipse4.6,方法如下:

打开eclipse根目录下的eclipse.ini配置文件,eclipse4.6默认配置如下:

[plain] view plain copy
-startup
plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.400.v20160518-1444
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m

在 -vmargs 前面增加 -vm参数来指定jdk路径,如我的jdk路径在d:\java文件夹下 :
-vm
D:\java\jdk1.8.0_91\bin\javaw.exe

添加 -vm参数后的配置文件如下:

[plain] view plain copy
-startup
plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.400.v20160518-1444
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
D:\java\jdk1.8.0_91\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m

然后再次运行eclipse.exe便能正常启动了。本回答被网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网