I have an existing project that uses #Override on methods that override interface methods, rather than superclass methods. I cannot alter this in code, but I would like Eclpse to stop complaining about the annotation, as I can still build with Maven.
How would I go about disabling this error?
Note: Due to project requirements, I need to compile for Java 1.5.
Using the #Override annotation on methods that implement those declared by an interface is only valid from Java 6 onward. It's an error in Java 5.
Make sure that your IDE projects are setup to use a Java 6 JRE, and that the "source compatibility" is set to 1.6 or greater:
Open the Window > Preferences dialog
Browse to Java > Compiler.
There, set the "Compiler compliance level" to 1.6.
Remember that Eclipse can override these global settings for a specific project, so check those too.
Update:
The error under Java 5 isn't just with Eclipse; using javac directly from the command line will give you the same error. It is not valid Java 5 source code.
However, you can specify the -target 1.5 option to JDK 6's javac, which will produce a Java 5 version class file from the Java 6 source code.
Do as follows:
Project -> Properties -> java compiler ->
Enable project specific settings - 'yes'
Compiler compliance - 1.6
generated class files and source compatibility - 1.5
Check also if the project has facet. The java version may be overriden there.
Project specific settings may be enabled. Select your project Project > Properties > Java Compiler, uncheck the Enable project specific settings or change Jdk 1.6 and above not forgetting the corresponding JRE.
Incase it does not work, remove your project from eclipse, delete .settings folders, .project, .classpath files. clean and build the project, import it back into eclipse and then reset your Java compiler. Clean and build your projectand eclipse. It worked for me
You could change the compiler settings to accept Java 6 syntax but generate Java 5 output (as I remember). And set the "Generated class files compatibility" a bit lower if needed by your runtime.
Update: I checked Eclipse, but it complains if I set source compatibility to 1.6 and class compatibility to 1.5. If 1.6 is not allowed I usually manually comment out the offending #Override annotations in the source (which doesn't help your case).
Update2:
If you do only manual build, you could write a small program which copies the original project into a new one, strips #Override annotations from the java sources and you just hit Clean project in Eclipse.
You can also try Retroweaver to create the Java5 version from Java6 classes.
Use Eclipse to search and replace (remove) all instances of "#Override". Then add back the non-interface overrides using "Clean Up".
Steps:
Select the projects or folders containing your source files.
Go to "Search > Search..." (Ctrl-H) to bring up the Search dialog.
Go to the "File Search" tab.
Enter "#Override" in "Containing text" and "*.java" in "File name patterns". Click "Replace...", then "OK", to remove all instances of "#Override".
Go to "Window > Preferences > Java > Code Style > Clean Up" and create a new profile.
Edit the profile, and uncheck everything except "Missing Code > Add missing Annotations > #Override". Make sure "Implementations of interface methods" is unchecked.
Select the projects or folders containing your source files.
Select "Source > Clean Up..." (Alt+Shift+s, then u), then "Finish" to add back the non-interface overrides.
I understood your problem, change your jdk from your jdk to greaterthan 1.5
By configuring that the IDE projects are setup to use a Java 6 JRE or above sometimes does not remove the eclipse error. For me a restart of the Eclipe IDE helped.
Even after changing the compiler compliance setting to 1.6 or 1.7 from
windows tab, then prefernces, then java, then compiler and setting the
compiler compliance, I was still having this issue. The idea is that we
need to go the the project folder, right click, Java and set compiler
compliance to 1.6 or higer. This worked for me.
Related
I'm attempting to compile Java 1.4 code that was created by IBM's WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse.
I'm under the assumption that the stubs generated should just compile as long as the runtime jars are available (they are).
Access restriction: The type QName is not accessible due to restriction on required library C:\Program Files\Java\jdk1.5.0_16\jre\lib\rt.jar
The full class name is javax.xml.namespace.QName
What exactly is going on here? Is this a case where I am trying to refactor a pig from sausage? Am I better off recreating the stubs?
There's another solution that also works.
Go to the Build Path settings in the project properties.
Remove the JRE System Library
Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.
This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first.
If you want a fundamental solution make sure you exclude the jar files with the same classes.
For me I have: javax.xml.soap.SOAPPart in three different jars: axis-saaj-1.4.jar, saaj-api-1.3.jar and the rt.jar
http://www.digizol.com/2008/09/eclipse-access-restriction-on-library.html worked best for me.
On Windows: Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
-> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning
On Mac OS X/Linux: Eclipse -> Preferences -> Java -> Compiler -> Errors/Warnings
-> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning
I met the same problem. I found the answer on the website: http://www.17ext.com.
First, delete the JRE System Libraries. Then, import JRE System Libraries again.
My guess is that you are trying to replace a standard class which ships with Java 5 with one in a library you have.
This is not allowed under the terms of the license agreement, however AFAIK it wasn't enforced until Java 5.
I have seen this with QName before and I "fixed" it by removing the class from the jar I had.
EDIT
http://www.manpagez.com/man/1/java/ notes for the option "-Xbootclasspath:"
"Applications that use this option for the purpose of overriding a class in rt.jar should not be deployed as doing so would contravene the Java 2 Runtime Environment binary code license."
The http://www.idt.mdh.se/rc/sumo/aJile/Uppackat/jre/LICENSE
"Java Technology Restrictions. You may not modify the Java
Platform Interface ("JPI", identified as classes contained
within the "java" package or any subpackages of the "java"
package), by creating additional classes within the JPI or
otherwise causing the addition to or modification of the
classes in the JPI. In the event that you create an
additional class and associated API(s) which (i) extends
the functionality of the Java platform, and (ii) is exposed
to third party software developers for the purpose of
developing additional software which invokes such
additional API, you must promptly publish broadly an
accurate specification for such API for free use by all
developers. You may not create, or authorize your
licensees to create, additional classes, interfaces, or
subpackages that are in any way identified as "java",
"javax", "sun" or similar convention as specified by Sun in
any naming convention designation."
I have been getting this error too, but my project is built on the command line using Maven and the tycho compiler (it's a set of OSGi plugins). After masses of sifting through people having the same problem but fixing it in Eclipse rather than on the command line, I found a message on the Tycho developer forum that answered my question, using configuration in pom.xml to ignore the compiler warning about the access restriction:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<compilerArgument>-warn:+discouraged,forbidden</compilerArgument>
</configuration>
</plugin>
More information can be found in the Tycho FAQ. This took me AGES to work out, so I figured I would assist anyone else trying to fix these access restriction errors from the command line by posting this answer.
Go to the Build Path settings in the project properties.
Windows -> Preferences -> Java Compiler
Remove the JRE System Library
Add another JRE with a "perfect match"
clean and build your project again. It worked for me.
I just had this problem too. Apparently I had set the JRE to 1.5 instead of 1.6 in my build path.
In addition to Nels Beckman's solution, I have the following tips:
Under Configure Build Path, I had to rearrange the order of my entries under Order and Export.
Additionally, as an Eclipse PDE developer, I needed to rearrange the order of my dependencies in my MANIFEST.MF, adding the problematic package as first on the list.
Playing with these dials, along with running Project > Clean in between, I was able to resolve these warnings.
for me this how I solve it:
go to the build path of the current project
under Libraries
select the "JRE System Library [jdk1.8xxx]"
click edit
and select either "Workspace default JRE(jdk1.8xx)" OR Alternate JRE
Click finish
Click OK
Note: make sure that in Eclipse / Preferences (NOT the project) / Java / Installed JRE ,that the jdk points to the JDK folder not the JRE C:\Program Files\Java\jdk1.8.0_74
Sorry for updating an old POST. I got the reported problem and I solved it as said below.
Assuming you are using Eclipse + m2e maven plugin, if you get this access restriction error, right click on the project/module in which you have the error --> Properties --> Build Path --> Library --> Replace JDK/JRE to the one that is used in eclipse workspace.
I followed the above steps and the issue is resolved.
In the case you are sure that you should be able to access given class, than this can mean you added several jars to your project containing classes with identical names (or paths) but different content and they are overshadowing each other (typically an old custom build jar contains built-in older version of a 3rd party library).
For example when you add a jar implementing:
a.b.c.d1
a.b.c.d2
but also an older version implementing only:
a.b.c.d1
(d2 is missing altogether or has restricted access)
Everything works fine in the code editor but fails during the compilation if the "old" library overshadows the new one - d2 suddenly turns out "missing or inaccessible" even when it is there.
The solution is a to check the order of compile-time libraries and make sure that the one with correct implementation goes first.
Go to the Java Build Path in the project properties. Remove the existing JRE System Library
Then Add it again i.e. Add Library-->JRE Lib--select jre--->Finish.
Lastly select order and export tab select JRE Lib and move on top. That's it.
Just change the order of build path libraries of your project. Right click on project>Build Path> Configure Build Path>Select Order and Export(Tab)>Change the order of the entries. I hope moving the "JRE System library" to the bottom will work. It worked so for me. Easy and simple....!!!
In my case there was a mismatch between the build path JRE and installed JRE on execution environment. I moved into Project > Properties > Java compiler. There was a warning message at the bottom.
I clicked on the links 'Installed JRE', 'Execution environment', 'Java build path' and changed the JDK version to 1.7 and the warning disappeared.
Adding a right JRE System through build path is the solution but your eclipse still may have the error.
To solve that go to Java Build path --> Order and Export and move your JRE system library on the top. This has solved my problem.
I'm attempting to compile Java 1.4 code that was created by IBM's WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse.
I'm under the assumption that the stubs generated should just compile as long as the runtime jars are available (they are).
Access restriction: The type QName is not accessible due to restriction on required library C:\Program Files\Java\jdk1.5.0_16\jre\lib\rt.jar
The full class name is javax.xml.namespace.QName
What exactly is going on here? Is this a case where I am trying to refactor a pig from sausage? Am I better off recreating the stubs?
There's another solution that also works.
Go to the Build Path settings in the project properties.
Remove the JRE System Library
Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.
This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first.
If you want a fundamental solution make sure you exclude the jar files with the same classes.
For me I have: javax.xml.soap.SOAPPart in three different jars: axis-saaj-1.4.jar, saaj-api-1.3.jar and the rt.jar
http://www.digizol.com/2008/09/eclipse-access-restriction-on-library.html worked best for me.
On Windows: Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
-> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning
On Mac OS X/Linux: Eclipse -> Preferences -> Java -> Compiler -> Errors/Warnings
-> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning
I met the same problem. I found the answer on the website: http://www.17ext.com.
First, delete the JRE System Libraries. Then, import JRE System Libraries again.
My guess is that you are trying to replace a standard class which ships with Java 5 with one in a library you have.
This is not allowed under the terms of the license agreement, however AFAIK it wasn't enforced until Java 5.
I have seen this with QName before and I "fixed" it by removing the class from the jar I had.
EDIT
http://www.manpagez.com/man/1/java/ notes for the option "-Xbootclasspath:"
"Applications that use this option for the purpose of overriding a class in rt.jar should not be deployed as doing so would contravene the Java 2 Runtime Environment binary code license."
The http://www.idt.mdh.se/rc/sumo/aJile/Uppackat/jre/LICENSE
"Java Technology Restrictions. You may not modify the Java
Platform Interface ("JPI", identified as classes contained
within the "java" package or any subpackages of the "java"
package), by creating additional classes within the JPI or
otherwise causing the addition to or modification of the
classes in the JPI. In the event that you create an
additional class and associated API(s) which (i) extends
the functionality of the Java platform, and (ii) is exposed
to third party software developers for the purpose of
developing additional software which invokes such
additional API, you must promptly publish broadly an
accurate specification for such API for free use by all
developers. You may not create, or authorize your
licensees to create, additional classes, interfaces, or
subpackages that are in any way identified as "java",
"javax", "sun" or similar convention as specified by Sun in
any naming convention designation."
I have been getting this error too, but my project is built on the command line using Maven and the tycho compiler (it's a set of OSGi plugins). After masses of sifting through people having the same problem but fixing it in Eclipse rather than on the command line, I found a message on the Tycho developer forum that answered my question, using configuration in pom.xml to ignore the compiler warning about the access restriction:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<compilerArgument>-warn:+discouraged,forbidden</compilerArgument>
</configuration>
</plugin>
More information can be found in the Tycho FAQ. This took me AGES to work out, so I figured I would assist anyone else trying to fix these access restriction errors from the command line by posting this answer.
Go to the Build Path settings in the project properties.
Windows -> Preferences -> Java Compiler
Remove the JRE System Library
Add another JRE with a "perfect match"
clean and build your project again. It worked for me.
I just had this problem too. Apparently I had set the JRE to 1.5 instead of 1.6 in my build path.
In addition to Nels Beckman's solution, I have the following tips:
Under Configure Build Path, I had to rearrange the order of my entries under Order and Export.
Additionally, as an Eclipse PDE developer, I needed to rearrange the order of my dependencies in my MANIFEST.MF, adding the problematic package as first on the list.
Playing with these dials, along with running Project > Clean in between, I was able to resolve these warnings.
for me this how I solve it:
go to the build path of the current project
under Libraries
select the "JRE System Library [jdk1.8xxx]"
click edit
and select either "Workspace default JRE(jdk1.8xx)" OR Alternate JRE
Click finish
Click OK
Note: make sure that in Eclipse / Preferences (NOT the project) / Java / Installed JRE ,that the jdk points to the JDK folder not the JRE C:\Program Files\Java\jdk1.8.0_74
Sorry for updating an old POST. I got the reported problem and I solved it as said below.
Assuming you are using Eclipse + m2e maven plugin, if you get this access restriction error, right click on the project/module in which you have the error --> Properties --> Build Path --> Library --> Replace JDK/JRE to the one that is used in eclipse workspace.
I followed the above steps and the issue is resolved.
In the case you are sure that you should be able to access given class, than this can mean you added several jars to your project containing classes with identical names (or paths) but different content and they are overshadowing each other (typically an old custom build jar contains built-in older version of a 3rd party library).
For example when you add a jar implementing:
a.b.c.d1
a.b.c.d2
but also an older version implementing only:
a.b.c.d1
(d2 is missing altogether or has restricted access)
Everything works fine in the code editor but fails during the compilation if the "old" library overshadows the new one - d2 suddenly turns out "missing or inaccessible" even when it is there.
The solution is a to check the order of compile-time libraries and make sure that the one with correct implementation goes first.
Go to the Java Build Path in the project properties. Remove the existing JRE System Library
Then Add it again i.e. Add Library-->JRE Lib--select jre--->Finish.
Lastly select order and export tab select JRE Lib and move on top. That's it.
Just change the order of build path libraries of your project. Right click on project>Build Path> Configure Build Path>Select Order and Export(Tab)>Change the order of the entries. I hope moving the "JRE System library" to the bottom will work. It worked so for me. Easy and simple....!!!
In my case there was a mismatch between the build path JRE and installed JRE on execution environment. I moved into Project > Properties > Java compiler. There was a warning message at the bottom.
I clicked on the links 'Installed JRE', 'Execution environment', 'Java build path' and changed the JDK version to 1.7 and the warning disappeared.
Adding a right JRE System through build path is the solution but your eclipse still may have the error.
To solve that go to Java Build path --> Order and Export and move your JRE system library on the top. This has solved my problem.
I'm attempting to compile Java 1.4 code that was created by IBM's WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse.
I'm under the assumption that the stubs generated should just compile as long as the runtime jars are available (they are).
Access restriction: The type QName is not accessible due to restriction on required library C:\Program Files\Java\jdk1.5.0_16\jre\lib\rt.jar
The full class name is javax.xml.namespace.QName
What exactly is going on here? Is this a case where I am trying to refactor a pig from sausage? Am I better off recreating the stubs?
There's another solution that also works.
Go to the Build Path settings in the project properties.
Remove the JRE System Library
Add it back; Select "Add Library" and select the JRE System Library. The default worked for me.
This works because you have multiple classes in different jar files. Removing and re-adding the JRE lib will make the right classes be first.
If you want a fundamental solution make sure you exclude the jar files with the same classes.
For me I have: javax.xml.soap.SOAPPart in three different jars: axis-saaj-1.4.jar, saaj-api-1.3.jar and the rt.jar
http://www.digizol.com/2008/09/eclipse-access-restriction-on-library.html worked best for me.
On Windows: Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
-> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning
On Mac OS X/Linux: Eclipse -> Preferences -> Java -> Compiler -> Errors/Warnings
-> Deprecated and restricted API -> Forbidden reference (access rules): -> change to warning
I met the same problem. I found the answer on the website: http://www.17ext.com.
First, delete the JRE System Libraries. Then, import JRE System Libraries again.
My guess is that you are trying to replace a standard class which ships with Java 5 with one in a library you have.
This is not allowed under the terms of the license agreement, however AFAIK it wasn't enforced until Java 5.
I have seen this with QName before and I "fixed" it by removing the class from the jar I had.
EDIT
http://www.manpagez.com/man/1/java/ notes for the option "-Xbootclasspath:"
"Applications that use this option for the purpose of overriding a class in rt.jar should not be deployed as doing so would contravene the Java 2 Runtime Environment binary code license."
The http://www.idt.mdh.se/rc/sumo/aJile/Uppackat/jre/LICENSE
"Java Technology Restrictions. You may not modify the Java
Platform Interface ("JPI", identified as classes contained
within the "java" package or any subpackages of the "java"
package), by creating additional classes within the JPI or
otherwise causing the addition to or modification of the
classes in the JPI. In the event that you create an
additional class and associated API(s) which (i) extends
the functionality of the Java platform, and (ii) is exposed
to third party software developers for the purpose of
developing additional software which invokes such
additional API, you must promptly publish broadly an
accurate specification for such API for free use by all
developers. You may not create, or authorize your
licensees to create, additional classes, interfaces, or
subpackages that are in any way identified as "java",
"javax", "sun" or similar convention as specified by Sun in
any naming convention designation."
I have been getting this error too, but my project is built on the command line using Maven and the tycho compiler (it's a set of OSGi plugins). After masses of sifting through people having the same problem but fixing it in Eclipse rather than on the command line, I found a message on the Tycho developer forum that answered my question, using configuration in pom.xml to ignore the compiler warning about the access restriction:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<compilerArgument>-warn:+discouraged,forbidden</compilerArgument>
</configuration>
</plugin>
More information can be found in the Tycho FAQ. This took me AGES to work out, so I figured I would assist anyone else trying to fix these access restriction errors from the command line by posting this answer.
Go to the Build Path settings in the project properties.
Windows -> Preferences -> Java Compiler
Remove the JRE System Library
Add another JRE with a "perfect match"
clean and build your project again. It worked for me.
I just had this problem too. Apparently I had set the JRE to 1.5 instead of 1.6 in my build path.
In addition to Nels Beckman's solution, I have the following tips:
Under Configure Build Path, I had to rearrange the order of my entries under Order and Export.
Additionally, as an Eclipse PDE developer, I needed to rearrange the order of my dependencies in my MANIFEST.MF, adding the problematic package as first on the list.
Playing with these dials, along with running Project > Clean in between, I was able to resolve these warnings.
for me this how I solve it:
go to the build path of the current project
under Libraries
select the "JRE System Library [jdk1.8xxx]"
click edit
and select either "Workspace default JRE(jdk1.8xx)" OR Alternate JRE
Click finish
Click OK
Note: make sure that in Eclipse / Preferences (NOT the project) / Java / Installed JRE ,that the jdk points to the JDK folder not the JRE C:\Program Files\Java\jdk1.8.0_74
Sorry for updating an old POST. I got the reported problem and I solved it as said below.
Assuming you are using Eclipse + m2e maven plugin, if you get this access restriction error, right click on the project/module in which you have the error --> Properties --> Build Path --> Library --> Replace JDK/JRE to the one that is used in eclipse workspace.
I followed the above steps and the issue is resolved.
In the case you are sure that you should be able to access given class, than this can mean you added several jars to your project containing classes with identical names (or paths) but different content and they are overshadowing each other (typically an old custom build jar contains built-in older version of a 3rd party library).
For example when you add a jar implementing:
a.b.c.d1
a.b.c.d2
but also an older version implementing only:
a.b.c.d1
(d2 is missing altogether or has restricted access)
Everything works fine in the code editor but fails during the compilation if the "old" library overshadows the new one - d2 suddenly turns out "missing or inaccessible" even when it is there.
The solution is a to check the order of compile-time libraries and make sure that the one with correct implementation goes first.
Go to the Java Build Path in the project properties. Remove the existing JRE System Library
Then Add it again i.e. Add Library-->JRE Lib--select jre--->Finish.
Lastly select order and export tab select JRE Lib and move on top. That's it.
Just change the order of build path libraries of your project. Right click on project>Build Path> Configure Build Path>Select Order and Export(Tab)>Change the order of the entries. I hope moving the "JRE System library" to the bottom will work. It worked so for me. Easy and simple....!!!
In my case there was a mismatch between the build path JRE and installed JRE on execution environment. I moved into Project > Properties > Java compiler. There was a warning message at the bottom.
I clicked on the links 'Installed JRE', 'Execution environment', 'Java build path' and changed the JDK version to 1.7 and the warning disappeared.
Adding a right JRE System through build path is the solution but your eclipse still may have the error.
To solve that go to Java Build path --> Order and Export and move your JRE system library on the top. This has solved my problem.
Anytime I have to re-import my projects into Eclipse (if I reinstalled Eclipse, or changed the location of the projects), almost all of my overridden methods are not formatted correctly, causing the error:
The method must override a superclass method
It may be noteworthy to mention this is with Android projects for whatever reason, the method argument values are not always populated, so I have to manually populate them myself. For instance:
list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
//These arguments have their correct names
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
}
});
will be initially populated like this:
list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
//This methods arguments were not automatically provided
public void onCreateContextMenu(ContextMenu arg1, View arg2,
ContextMenuInfo arg3) {
}
});
The odd thing is, if I remove my code, and have Eclipse automatically recreate the method, it uses the same argument names I already had, so I don't really know where the problem is, other then it auto-formatting the method for me.
This becomes quite a pain having to manually recreate ALL my overridden methods by hand. If anyone can explain why this happens or how to fix it. I would be very happy.
Maybe it is due to the way I am formatting the methods, which are inside an argument of another method?
Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with #Override, but in Java 1.5 can only be applied to methods overriding a superclass method).
Go to your project/IDE preferences and set the Java compiler level to 1.6 and also make sure you select JRE 1.6 to execute your program from Eclipse.
With Eclipse Galileo you go to Eclipse -> Preferences menu item, then select Java and Compiler in the dialog.
Now it still may show compiler compliance level at 1.6, yet you still see this problem. So now select the link "Configure Project Specific Settings..." and in there you'll see the project is set to 1.5, now change this to 1.6. You'll need to do this for all affected projects.
This byzantine menu / dialog interface is typical of Eclipse's poor UI design.
In case this happens to anyone else who tried both alphazero and Paul's method and still didn't work.
For me, eclipse somehow 'cached' the compile errors even after doing a Project > Clean...
I had to uncheck Project > Build Automatically, then do a Project > Clean, and then build again.
Also, when in doubt, try restarting Eclipse. This can fix a lot of awkward, unexplainable errors.
To resolve this issue, Go to your Project properties -> Java compiler -> Select compiler compliance level to 1.6-> Apply.
The answer by Paul worked for me partially. I still had one error then. So, in addition to that, I also had to go to Properties-> Project Facets and there set the Java version from 1.5 to 1.6.
Maybe that helps.
If nothing of the above helps, make sure you have a proper "Execution environment" selected, and not an "Alternate JRE".
To be found under:
Project -> Build Path -> Libraries
Select the JRE System Library and click Edit....
If "Alternate JRE ..." is selected, change it to a fitting "Execution Environment" like JavaSE-1.8 (jre1.8.0_60). No idea why, but this will solve it.
Guys in my case none of the solutions above worked.
I had to delete the files within the Project workspace:
.project
.classpath
And the folder:
.settings
Then I copied the ones from a similar project that was working before. This managed to fix my broken project.
Of course do not use this method before trying the previous alternatives!.
This is my second time encounter this problem.
first time according the alphazero's recommendation it worked.
but in the second time I set to 1.6 it don't work it just like 'CACHE' this error after clean and rebuild.
Try to switch off 'Build Automatically' as Rollin_s said -> error still here!
So I removed the problem project (already set to 1.6) from Package Explorer and import it again -> it start a rebuild and no error this time
Hope this help someone
In my case this problem happened when I imported a Maven project into Eclipse. To solve this, I added the following in pom.xml:
<properties>
...
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Then in the context menu of the project, go to "Maven -> Update Project ...", and press OK.
That's it. Hope this helps.
Fixing must override a super class method error is not difficult, You just need to change Java source version to 1.6 because from Java 1.6 #Override annotation can be used along with interface method. In order to change source version to 1.6 follow below steps :
Select Project , Right click , Properties
Select Java Compiler and check the check box "Enable project specific settings"
Now make Compiler compliance level to 1.6
Apply changes
In my case, none the solutions above works. I have to checkout my source code to another folder. From eclipse select File > Switch workSpaces > Other... and then import code to the new workspaces. it works after that.
This happens when your maven project uses different Compiler Compliance level and Eclipse IDE uses different Compiler Compliance level. In order to fix this we need to change the Compiler Compliance level of Maven project to the level IDE uses.
1) To See Java Compiler Compliance level uses in Eclipse IDE
*) Window -> Preferences -> Compiler -> Compiler Compliance level : 1.8 (or 1.7, 1.6 ,, ect)
2) To Change Java Compiler Compliance level of Maven project
*) Go to "Project" -> "Properties" -> Select "Java Compiler" -> Change the Compiler Compliance level : 1.8 (or 1.7, 1.6 ,, ect)
It's 2020 -
Project>Right Click>Java Compiler>Compiler Compliance Level> Change this to 1.8 [or latest level]
I do not believe this is a duplicate of any of the previous questions concerning Java in Eclipse.
yesterday my machine updated its java version, and after it did that I opened my Eclipse IDE and found I couldn't build most of my Java projects. The last time I used eclipse everything worked and I had not changed any settings.
I should be using java 1.7_80 (my work projects require this), but now when I build my projects eclipse says it is looking for java 1.8_71- but then eclipse says its using java 1.8_77; all the while my Java compiler settings still says I'm using java 1.7...
The Question: Are there any other places in Eclipse where it sets what version of Java is used?
Note: Java 1.7_80 is still in my PATH System Environment variable; those other newer versions are not and never were. I am using ANT. Below are some images to show my problems and settings.
Check Window->Preferences->Installed JREs, there eclipse uses the checked JRE to compile and run your product per default.
There is also a "Java Runtime Environment" option in your Run configuration.
You can also specify project specific Java Compiler options, rightclick Properties on your project.
Edit: for ant launches, see printscreen below:
Edit2: ok I think for Ant, compiler options are irelevant.
What you can try is storing your ant launch in your project and open it with a text editor and search for invalid java configurations:
open your ant launch
goto Common
change to Shared file
choose your project
Try right clicking on the project and select "Build Path" and "Configure build path". Then select the library and change the library to the desired one. Also to check which version of java is install you can use "java -version" in terminal/ command prompt.