I am writing serialization code for eclipse I am trying to use FileOutputStream with try-with-resource but I am getting a error message : "Resource specification not allowed here for source level below 1.7" And as fix Eclipse is showing the message "Change project compliance and JRE to 1.7". This is a new error for me, please help.
public static void main(String[] args) {
Employee employeeOut = null;
try(FileOutputStream fos = new FileOutputStream("Employee.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos) ){
}
}
I want to compile this class.
Your project setup is wrong. To fix that, right click your project, then select Properties.
Select "Build Path", and the tab "Libraries".
Select JRE System Library, and click "Edit...".
Select "Execution environment" "JavaSE-1.8", then "Finish".
Now select "Java Compiler" on the left.
Make sure "Use compilance from execution environment 'JavaSE-1.8' on the 'Java Build Path'" is checked.
This should fix your problem.