Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

void is an invalid type for the variable main

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Hello , I am a newbie to in Java on Vaadine. Can anyone tell me why I am getting error :void is an invalid type for the variable main on line 12 highlight? thanks

Code:
package com.example.tayo;

import com.vaadin.Application;
import com.vaadin.ui.*;

public class TayoogundehindeApplication extends Application {
	@Override
	public void init() {
		Window mainWindow = new Window("tayoApplication");
			[COLOR=red]public static void main(String[]args);[/color]{
			System.out.println("Hello Teacher");
			System.out.println("This is Tayo");
			System.out.println("Well this is getting better!");
			System.out.println("I've even got some buttons!");
			System.out.println("Please click my buttons");
		}
		Label label = new Label("The right Button");
		Label label1 = new Label("The wrong Button");
		mainWindow.addComponent(label1);
		setMainWindow(mainWindow);
	}

}
 
You wrapped your main method inside of your init method.
It should be pulled outside of init, and call on init to do any work defined there.
Something like:
Code:
public class TayoogundehindeApplication extends Application {
    public static void main(String[]args);{
        TayoogundehindeApplication ta = new TayoogundehindeApplication();
        ta.init();
    }

    @Override
    public void init() {
        Window mainWindow = new Window("tayoApplication");
        System.out.println("Hello Teacher");
        System.out.println("This is Tayo");
        System.out.println("Well this is getting better!");
        System.out.println("I've even got some buttons!");
        System.out.println("Please click my buttons");
        Label label = new Label("The right Button");
        Label label1 = new Label("The wrong Button");
        mainWindow.addComponent(label1);
        setMainWindow(mainWindow);
    }

}
 
Small typo, I now see :-:)
Code:
 public static void main(String[] args) {
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top