facebook

Eclipse will not compile new 1.5 code

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #229071 Reply

    Curtis Fisher
    Participant

    I am working with examples from the book, Core Javaâ„¢ 2 Volume II – Advanced Features, Seventh Edition by Cay S. Horstmann, Gary Cornell and using the following example, my code compiles fine with the DOS prompt, but errors galore appear in MyEclispe, as well as the Java Perspective.

    import java.util.*;

    public class MapTest {
    public static void main(String[] args)
    {
    Map<String, Employee> staff = new HashMap<String, Employee>();
    staff.put(“144-25-5464”, new Employee(“Amy Lee”));
    staff.put(“567-24-2546”, new Employee(“Harry Hacker”));
    staff.put(“157-62-7935”, new Employee(“Gary Cooper”));
    staff.put(“456-62-5527”, new Employee(“Francesca Cruz”));

    // print all entries

    System.out.println(staff);

    // remove an entry

    staff.remove(“567-24-2546”);

    // replace an entry

    staff.put(“456-62-5527”, new Employee(“Francesca Miller”));

    // look up a value

    System.out.println(staff.get(“157-62-7935”));

    // iterate through all entries

    for (Map.Entry<String, Employee> entry : staff.entrySet())
    {
    String key = entry.getKey();
    Employee value = entry.getValue();
    System.out.println(“key=” + key + “, value=” + value);
    }
    }
    }

    //New Class
    /**
    A minimalist employee class for testing purposes.
    */
    class Employee
    {
    /**
    Constructs an employee with $0 salary.
    @param n the employee name
    */
    public Employee(String n)
    {
    name = n;
    salary = 0;
    }

    public String toString()
    {
    return “[name=” + name + “, salary=” + salary + “]”;
    }

    private String name;
    private double salary;
    }

    Eclipse does not seem to undetstand the Generics (read http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf ) that are included in the code. Is there something I need to do in order to compile, or will MyEclipse use the new features in 1.5?

    Thanks,

    Curtis Fisher

    #229075

    Riyad Kalla
    Member

    You need to be using Eclipse 3.1M6 and MyEclipse 3.8.4 BETA For M6 in order to get JDK 1.5 syntax support.

    #229076

    Curtis Fisher
    Participant

    Thanks, will do…

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Eclipse will not compile new 1.5 code

You must be logged in to post in the forum log in