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

转载自:https://blog.csdn.net/gnail_oug/article/details/51925804;个人做了些小修改。

今天下载了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
 
  1. -startup  
  2. plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar  
  3. --launcher.library  
  4. plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.400.v20160518-1444  
  5. -product  
  6. org.eclipse.epp.package.jee.product  
  7. --launcher.defaultAction  
  8. openFile  
  9. -showsplash  
  10. org.eclipse.platform  
  11. --launcher.defaultAction  
  12. openFile  
  13. --launcher.appendVmargs  
  14. -vmargs  
  15. -Dosgi.requiredJavaVersion=1.8  
  16. -XX:+UseG1GC  
  17. -XX:+UseStringDeduplication  
  18. -Dosgi.requiredJavaVersion=1.8  
  19. -Xms256m  
  20. -Xmx1024m  


在 -vmargs 上一行--launcher.appendVmargs的上一行增加 -vm参数来指定jdk路径,如我的jdk路径在d:java文件夹下 :

-vm
D:javajdk1.8.0_91injavaw.exe

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

[plain] view plain copy
 
  1. -startup  
  2. plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar  
  3. --launcher.library  
  4. plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.400.v20160518-1444  
  5. -product  
  6. org.eclipse.epp.package.jee.product  
  7. --launcher.defaultAction  
  8. openFile  
  9. -showsplash  
  10. org.eclipse.platform  
  11. --launcher.defaultAction  
  12. openFile
  13. -vm  
  14. D:javajdk1.8.0_91injavaw.exe  
  15. --launcher.appendVmargs  
  16. -vmargs  
  17. -Dosgi.requiredJavaVersion=1.8  
  18. -XX:+UseG1GC  
  19. -XX:+UseStringDeduplication  
  20. -Dosgi.requiredJavaVersion=1.8  
  21. -Xms256m  
  22. -Xmx1024m  


然后再次运行eclipse.exe便能正常启动了。

原文地址:https://www.cnblogs.com/silentdoer/p/8697333.html