I have been having problems with appcompat_v7, someone told me to use Android-21 target. An error with that got me told to use JDK 1.8. I currently have JDK 1.6 installed. How do I switch Eclipse over to use JDK 1.8? I see no place to set the JDK path. The other time this question was asked, the questioner was referred to the JRE settings ... but the JDK is not the JRE, there are two separate paths. How do I get Eclipse to use the new JDK?
Project Menu > Properties menu item > Java Compiler > Compiler Compliance Level
Select your Java version from the pulldown menu. Obviously, you'll need to install Java 1.8 first to get it to show up as an installed version.
Related
I installed Eclipse mars with java JDK8 but was was having lots of problems with it so I uninstalled it changed back to JDK7 and now I'm getting a strange compiler error in a few of my projects. I noticed that when I went into, Windows->Preferences-> Java->Installed JREs, there is an error message at the top saying that "The selected JRE does not support the ...rent compiler compliance level of 1.8" but when I check the compiler compliance level its set to 1.7
Ok so I decided to try starting a new project and when trying to build it a warning came up that my workspace compliance level was at level 1.8...changing the workspace fixed the problem. So new is it possible to change the workspace compliance level or should I just import my projects into a new workspace?
I tried importing into a new workspace,same problem. So I started new project in a new workspace, copyed and pasted the code in a voila it works! Very annoying if I have to do that for every class in every project I want.
Check your compliance settings in:
Preferences > Java > Compiler
Make sure the default is set to 1.7 as it may have defaulted to 1.8 after the initial install/run.
Also check project-specific compliance settings in:
(Project) Properties > Java Compiler
I changed Windows ->Preference->Java->Installed JREs to jdk1.7.0_79 and right clicked the project, Properties ->Java Build Path, made sure that under Libraries tab, it is JRE System Library[JavaSE-1.7]. Clicked Project ->Clean. Right clicked the project again, Properties ->Java Compiler, checked Use compliance from execution environment 'JavaSE-1.7' on the 'Java Build Path'.Then it worked.
If you already changed all settings to 1.7 (both in the eclipse preferences and the project properties) check your project's build path. How? Easy, after you've imported your project, right-button click it and select Build path > Configure Build Path. Then, check if you have your JRE system library correctly set.
If even this is set up ok, I would say that you probably have some code that can only be compiled by jdk 8 and you're trying to use jdk7 compliance level, which eclipse warns you about. An example of this is using lambda functions, which can only be compiled with java 8 as far as I know.
Go to Windows >> Preferences>>Compiler >> Unselect default
compliance settings >> select the compiler compliance level to 1.8
This should reflect in generated .class files compatibility
as 1.8 and source compatibility as 1.8 Step Step
Apply it Step
now click on apply and close
clean and build the project.
I have similar issue with Mars on Pydev environment. Seems that Mars want java jre 1.7.0, so for me was work by copy inside(create if not avaiable) eclipse\jre\ folder and copy the 1.7.0 version of jre inside
I want to make a mod for Minecraft, and i have Java and JDK 7, because it's not compatible with Java 8. but the new Eclipse is for Java 8, and i can't find anywhere a Eclipse version for Java 7.
You can work with any JDK if your Eclipse supports the latest one. You need to install JDK7, then you go to Window, Preferences. Type installed in the field and choose Installed JREs. Then, give the path of your JDK. Finally, right click on your project, Properties, Java compiler and select the appropriate JDK and compiler compliance.
I am having some trouble updating the compiler compliance of my eclipse workspace (I am actually using RTC, but it is essentially eclipse).
Currently, it uses a jdk of 1.6 so I can change the JDK compliance to a limit of 1.6.
However, I am using jdk 1.7 for my project -I have added it as a JRE -
preferences --> Java --> Installed JRE --> added jre with the jdk 1.7 directory.
However, even though I use this as the default JRE it does not allow me to change the compiler compliance level to 1.7.
I am guessing that there is something I am missing.
Any help would be greatly appreciated
The Compiler compliance level is Version Dependent in eclipse. If you are using Eclipse 3.7 or lower then you won't get 1.7 compliance. Use Eclipse JUNO or higher.
For more on JDT Core 7 and its release related information
UPDATE:
Even eclipse 3.7.1 version supports Java 7 features and compliance level.
I use eclipse 3.6.1 with installed JRE 1.7 and I was able to set Java compliance level to 1.7 (on the workspace level - preferences).
In some workspaces I could do that right in the Preferences, in some workspaces I had to do that in a "hard way" updating several properties in the file:
.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs
Here are changed lines:
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
Maybe it was just enough to change the line with "org.eclipse.jdt.core.compiler.compliance" property , but I did all three for the sake of completeness and consistency.
If you are using eclipse 3.7 then you add 1.7 into compliance level by following way:-
right click on project
click on Build path->Configure Build Path->project Facets
there you can see one link 'convert to faceted form'. click on it
mark java and select verion 1.7 from dropdown which is present in front of java tab
click on apply and click ok
now you can see that 1.7 version is appeared in compliance level
Note:- Before above step you have to add JRE System library in Build path for jdk1.7
Right click on project you have in use, click on Properties,
enter image description here
go on "Compiler compilance level", and select 1.8
enter image description here
Select your project, then go to Project -> properties.
In Properties -> Java Compiler.
Under JDK Compliance if "use compliance from execution environment " is checked then uncheck it and you would see a dropdown in from of Compiler Compliance Level. Chose your desired version from here.
Click on Apply and Close.
Hopefully, this would resolve the issue.
I need to write a project that's only compatible with Java 1.5. I have Java 1.6 installed. Is there some form of backwards compatibility to get Eclipse to compile with 1.5?
Do I have to install Java 1.5 to get it to show here? Or maybe there is another way?
.
Click on the Add Library button. It brings your screen to point to the Java location.
Select "Directory", button right besides JRE home and point to the installed folder location.
Even though you want to just 1.5 compiler project, you can achieve it by changing compiler settings in Eclipse instead of removing 1.6 JRE and add 1.5 JRE.
GOTO -->JAVA--Compiler---> and change compiler level to `1.5` instead of `1.6`
As davidfmatheson suggested,
Just be careful, especially if you're setting this up for a team of people to work on. If anyone uses anything that is new or changed in 1.6, it will compile, but not run in an environment with JRE 1.5.
Click on the Window tab in Eclipse, go to Preferences and when that window comes up, go to Java → Installed JREs → Execution Environment and choose JavaSE-1.5. You then have to go to Compiler and set the Compiler compliance level.
Right click project -> Properties -> Java Build Path -> select JRE System Library click Edit and select JDK or JRE after then click Java Compiler and select Compiler compliance level to 1.8
If you are using maven build tool then add the below properties to it and doing a maven update will solve the problem
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
In the preferences section under Java -> Installed JREs click the Add button and navigate to the 1.5 JDK home folder. Then check that one in the list and it will become the default for all projects:
Eclipse - specific Project change JDK Version -
If you want to change any jdk version of A specific project than you have to click ---> Project --> JRE System Library --> Properties ---> Inside Classpath Container (JRE System Library) change the Execution Environment to which ever version you want e.g. 1.7 or 1.8.
The JDK (JAVA_HOME) used to launch Eclipse is not necessarily the one used to compiled your project.
To see what JRE you can select for your project, check the preferences:
General → Java Installed JRE
By default, if you have not added any JRE, the only one declared will be the one used to launched Eclipse (which can be defined in your eclipse.ini).
You can add any other JRE you want, including one compatible with your project.
After that, you will need to check in your project properties (or in the general preferences) what JRE is used, with what compliance level:
(source: standartux.fr)
See the page Set Up JDK in Eclipse. From the add button you can add a different version of the JDK...
As I was facing this issue minutes ago, in case you are trying to open an existing project in an environment with a newer JDK, make sure you pdate the JDK version in Project Properties -> Project Facets -> Java.
While creating new Java project in Eclipse I got following warning "The current workspace uses 1.4 JRE..."
I have JRE7 on my system. I have added following lines in eclipse.ini
-vm
C:\Java\jre7\bin\javaw.exe
I have added JRE7 to Installed JREs through Windows -> Preferences-> Installed JREs.
Still under Compiler tab I can see only compiler compliance level till 6.
How can I change workspace JRE to JRE 7 ?
Java 7 support is only available since Eclipse Indigo SR1 (released about a month ago). So, upgrade Eclipse.
I also have jre7, and it really doesn't matter if it only says that is compliant with 1.6, because the project will look for the java compiler specified by the jre/jdk used in the project.
I also recommend you use the jdk instead of the jre, and set the environment variable JAVA_HOME, there's lots of tutorials on this in Google.
The issue where it is compiling with 1.4 but the workspace Preferences Compiler setting is 1.6 seems to be the issue described in this bug:
Bug 499675 - Global compiler settings ignored after restarting, defaults to 1.4 even though 1.8 displayed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=499675
where the workaround is to change the workspace setting to a different version number and then back to 1.6. That would enable the workspace to compile with 1.6.
To compile with 1.7 you'd need to upgrade eclipse as in BalusC's answer.