Eclipse->New Android Projects always compile java 1.4 - java

Everytime I add/create or copy a Project inside my Eclipse-Workspace it will be recognized as a Java 1.4 Project, which leads to a sum of errors. I have to fix this myself under properties->java-compiler and check 1.6 there. So I have a few questions on that:
Is it possible to pre-define which compiler Eclipse has to choose?
Is there a config file telling eclipse which compiler to choose?

Check under Window -> Preferences -> Java -> Compiler. There is "Compiler compliance level", it should be set to your desired level. :)
If that does not work, go to the "New Java Project" dialog and pres "Configure JREs". Make sure your desired JRE is selected.

Window->Preferences->Java->Compiler

Related

How do I change the default Eclipse Oxygen compiler compliance level from 9 to 1.8 and not have it revert back to 9?

When I open a workspace in Eclipse Oxygen, the default compiler compliance level is set to 9. I change it in Preferences > Java > Compiler back to 1.8 and click Apply. It works, until I close Eclipse and reopen it and now it's back to 9. How can I make the change stick?
Note:
I know that /instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance is set somewhere to 9, but I can't find out where that is.
I cannot replicate your problem of compliance changes not persisting across restarts, but you can manually set them rather than using Eclipse's GUI. To do that:
Close Eclipse.
Locate your preferences file. This is a text file containing many of settings you normally assign in Eclipse using Window > Preferences. The file will be in your workspace directory within the .metadata directory with the following name:
.metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.jdt.core.prefs
Open the file org.eclipse.jdt.core.prefs in a text editor and edit the following three lines:
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
org.eclipse.jdt.core.compiler.compliance=9
org.eclipse.jdt.core.compiler.source=9
Replace the three instances of "9" with "1.8" for JDK 1.8 compliance (or "10" for JDK 10 compliance). Those three properties correspond to the three fields you see on the Compiler screen which specify a version, as shown below.
Restart Eclipse and go to Preferences > Java > Compiler. The settings for the compiler should now all be set to 1.8:
This approach worked for me. However, even if this approach solves your problem, you could still raise a Bug Report with Eclipse since it should not be necessary to manually edit the preferences file.
My workspace settings were getting over-written by user-specific settings stored in ~/.eclipse/org.eclipse.oomph.setup/setups/user.setup. Specifically, that file included those leftover setup lines from a previous installation:
<setupTask
xsi:type="setup:PreferenceTask"
key="/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.codegen.targetPlatform"
value="9"/>
<setupTask
xsi:type="setup:PreferenceTask"
key="/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.compliance"
value="9"/>
<setupTask
xsi:type="setup:PreferenceTask"
key="/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.compiler.source"
value="9"/>
</setupTask>
Solution:
Remove the lines above from ~/.eclipse/org.eclipse.oomph.setup/setups/user.setup.
Note:
Thanks to #skomisa who helped me figure this out.

Using jdk1.8 and recieving weird error

I have this code: ArrayList<Integer> num_array = new Arraylist<Interger>();
WHY am I getting this error: "Syntax error, parameterized types are only available if source level is 1.5 or greater"
In your eclipse, go to the menu under Window -> Preferences -> Java -> Compiler. That will allow you to change the java version with the "Compiler compliance level" setting, since it appears to be set to 1.4 or lower.
EDIT: Also, if that does not work, right click on the project in the Project Explorer to the left of the screen, choose Properties and select Java Compiler. Apply the same changes here as well.

Can't change the jre version in eclipse

I got an error "Syntax error, 'for each' statements are only available if source level is 1.5 or greater" in eclipse.
The jre system library being used is oracle-java-6 and I also enable project specific settings and set complier level to 1.6 but the error is still there.
Please help, thanks ahead.
4. ERROR in /home/johnny/Application/GWTPV/ParaViewWeb/WebServer/PWApp/src/org/paraview/server/AvailableDataFilter.java (at line 65)
ArrayList<FileBean> tmpfileNames = new ArrayList<FileBean>();
^^^^^^^^
Syntax error, parameterized types are only available if source level is 1.5
Look at the tab "Java compiler" in your project properties. If your default jdk compilance is less than 1.5 you should check "Enable project specific settings" and edit "Compiler compilance level" to 1.5, 1.6...
Check out the build path configuration (In the package viewer select the project root element and right mouse clic). Then check the Library setting. Often changing the JRE leaves the Library still set to 1.5.
Right click on the project -> Build Path -> Configure build path
or 1B. Right click on project -> properties -> Java build path
or 1C. Find the error in the Problems view, select it and click [ctrl]+[1] -> Configure build path
Open Libraries tab -> choose add library (or edit an exsting JRE on the list) -> JRE -> Alternate JRE -> click Installed JREs -> choose one
If you can't see the JRE you're looking for on the list (that is version 1.5 or greater):
Add -> standard JVM -> in JRE home field enter the location of your JRE on the disc.

Eclipse - I have Java 1.6 set in my Window-Preferences, but the compiler is giving errors about the #Override

Would anyone know why this happens? I seem to have Java 1.6 set, but I still get the #Override errors as though the system thinks I am on 1.5 which is strange.
Any thoughts on why this happens?
EDIT
The error message is
The method method(parametertypes) of type Type must override a
superclass method
You need to set both the compliance level
and add the appropriate JRE library (right-click the project and select "properties" to get the screen below)
You may need to "clean" the project (Project > Clean...) after completing the above steps.
If you haven't already, navigate to Window -> Preferences -> Java -> Compiler and set the Compiler compliance level to 1.6.
This assumes that you've already set 1.6 on the project's build path.

Android: rebuild now requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Why remove of #Override? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties
After rebuilding my PC I get this error on importing my projects.
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.
I have seen this raised on SO and I can fix my projects by doing the Fix Proj, and then removing all my #OVerrides.
this question is why do I now require to remove #Overrides? and will this alter my projects in anyway?
cheers
Edit to add walkthrough information.
I import a project, I get the error shown above. I then do the Android Tools > Fix Project Properties. This now sets Project>Properties Java Compile to Compiler Compliance Level 1.5
After this I am left with a series of errors within my java files. on this particular project my errors are on
#Override
public void run() {...
Error marker to left of error read...
Multiple markers at this line
- The method run() of type new Runnable(){} must override a superclass
method
- implements java.lang.Runnable.run
the error hover in eclipse suggests I remove the #Override to fix this issue, and if I do remove the #Override it does fix the issue and my project now compiles and runs.
Is this incorrect?
p.s. I just wrote all that up, changed the Java Compliance level to 1.6 and all the override errors went away! Could someone explain (and I totally appreciate this might be totally off topic) why?
Dont remove any #overide notation.
you must set project compatibility to Java 5.0 or Java 6.0.
To do that, 2 options:
1) right-click on your project and select "Android Tools -> Fix Project Properties" (if this din't work, try second option)
2) right-click on your project and select "Properties -> Java Compiler", check "Enable project specific settings" and select 1.5 or 1.6 from "Compiler compliance settings" select box.
refer this LINK for reference
FIRST UPDATE EVERYTHING....
Now right click on your project and select "Android Tools" then "Add Support library" it will update then try the stuff i copied from above....
1) right-click on your project and select "Android Tools -> Fix Project Properties" (if this din't work, try second option)
2) right-click on your project and select "Properties -> Java Compiler", check "Enable project specific settings" and select 1.5 or 1.6 from "Compiler compliance settings" select box.
Big Thanks to Agarwal Shankar for the start...

Categories

Resources