Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 141700

Summary: java.lang.NoSuchMethodError: main when using generic class types
Product: [Eclipse Project] JDT Reporter: Richard <codesamuraix>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: codesamuraix
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Richard CLA 2006-05-14 15:48:56 EDT
I created a java class from an example for a book on generic class types. I had no syntax and no grammar errors. I ran it as a java application and got this error, java.lang.NoSuchMethodError: main Exception in thread "main". I am using eclipse Version: 3.2.0 Build id: I20060331-2000 with J2SE_1.5.0_06. I will attach the log file.



package src;

public class LinkedList<T> {
    private ListItem current = null;
	private ListItem end = null;
	private ListItem start = null;

	// Default constructor - create an empty list
	public LinkedList() {}
	
    // Constructor to create a list containing one ListItem 
	public LinkedList(T item) {
		if (item != null) {
			current=end=start = new ListItem(item);
		}
	}

	// Constructor to create a list from an arrray of ListItem 
	public LinkedList(T[] items) {
		if (items != null) {
			// Add the items to the list
			for(int i = 0; i < items.length; i++) {
		    }
		    current = start;
		}
	}

	// Add an item object to the list
	public void addItem(T item) {
		ListItem newEnd = new ListItem(item);           // Create a new ListItem
		if(start == null) {                             // Is the list empty?
			start = end = newEnd;                       // Yes, so new element is start and end
		} else {                                        // No, so append new element
			end.next = newEnd;                          // Set next variable for old end
			end = newEnd;                               // Store new item as end
		}
	}

	// Get first object in the list
	public T getFirst() {
		current = start;
		return start == null ? null : start.item;
	}
	
	// Get next object in the list
	public T getNext() {
		if(current != null) {
		    current = current.next;                      // Get the reference to the next item
		}
		return current == null ? null : current.item;
	}
	
	private class ListItem {
        // Constructor
		public ListItem(T item) {
			this.item = item;         // Store the item
			next = null;              // Set next to end point
		}

		// Return class name & object
		public String toString() {
			return "ListItem " + item;
		}
		
		ListItem next;                // Refers to the next in the list
		T item;                       // The item in this ListItem
	}
}
Comment 1 Richard CLA 2006-05-14 15:51:12 EDT
Sorry, there is no .log file.
Comment 2 Pascal Rapicault CLA 2006-05-14 19:46:35 EDT
Moving to JDT core. 
The latest version of eclipse available is 3.2 RC4 and it contains many bug fixes.
Comment 3 Olivier Thomann CLA 2006-05-14 20:53:52 EDT
This class has no main method and therefore cannot be run as a java application.
Closing as INVALID.
Comment 4 Richard CLA 2006-05-15 07:55:59 EDT
Thanks. closing.