diamond operator is not supported in -source 1.5

2

I have the following code which shows some products in a combobox

<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%

        List<String> productos = new ArrayList<>();
        productos.add("TV");
        productos.add("PC");
        productos.add("Stereo");
        productos.add("Iphone");

        %>

        <select>
            <%
                for (String p : productos)
                {
                    out.println("<option>" + p + "</option>");
                }

            %>
        </select>
    </body>
</html>

But when I run it, I get the following error

  

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP   PWC6199: Generated servlet error:   source value 1.5 is obsolete and will be removed in a future release   PWC6199: Generated servlet error:   target value 1.5 is obsolete and will be removed in a future release   PWC6199: Generated servlet error:   To suppress warnings about obsolete options, use -Xlint: -options.   PWC6197: An error occurred at line: 17 in the jsp file: /index.jsp   PWC6199: Generated servlet error:   diamond operator is not supported in-source 1.5     (use -source 7 or higher to enable diamond operator) <

I have version 8 of Java, version 4.1.1 of Glassfish and the latest version of Netbeans.

    
asked by Lucas. D 24.10.2017 в 20:23
source

1 answer

1

Probably use Java 5 but the diamond operator < > is the feature of Java 7. So, there are two solutions:

Update to Java 7 Do not use the diamond operator < >

Instead of declaring ArrayList like this:

List<String> productos = new ArrayList<>();

Declare ArrayList Like

List<String> productos = new ArrayList(); 

that is, do not use the < > on the right side

    
answered by 24.10.2017 / 22:13
source