maven+eclipse编译常见问题
问题:
[ERROR] Unable to locate the Javac Compiler in: [ERROR] C:\Program Files (x86)\Java\jre1.5.0_11\..\lib\tools.jar [ERROR] Please ensure you are using JDK 1.4 or above and [ERROR] not a JRE (the com.sun.tools.javac.Main class is required). [ERROR] In most cases you can change the location of your Java [ERROR] installation by setting the JAVA_HOME environment variable.
网上有人说在eclipse.ini文件中设置
-vm
C:\Program Files\Java\jdk1.6.0_21\jre\bin\javaw.exe
或者
window-->preferences-->java-->Installed JREs:将路径设置成jdk的路径
这些方法都是影响这个ide环境的,更好的方法是针对项目进行修改:
最佳解决方案(我懒就不翻译了):
You can install as many different versions of Java — JREs and JDKs — as you like, and tell Eclipse which one to use for each project.
First step is to install the JDK 1.5 on your machine (JDK is short for 'Java [SE] Development Kit', look for that on the Oracle download site). The JDK includes a JRE, so to make life easier you can usually just install the JDK and not worry about the JRE/JDK distinction.
Second step is to tell Eclipse about the new JDK. Go to Preferences... then Java > Installed JREs. Click the Search... button and Eclipse should find your newly installed JDK 1.5 and add it to the list.
Final step is to allocate that JDK 1.5 to your project. Bring up the Properties menu for your project (right-click it). Then set these values:
-
Java
Compiler tab
- Tick Enable project specific settings
- Set Compiler Compliance level to 1.5
-
Java
Build Path tab, Libraries subtab
- Find the JRE System Library item, click Edit...
- Set Alternate JRE to your newly installed JDK 1.5

浙公网安备 33010602011771号