INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

void is an invalid type for the variable main

void is an invalid type for the variable main

void is an invalid type for the variable main

(OP)
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");
            public static void main(String[]args);{
            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);
    }

}

RE: void is an invalid type for the variable main

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);
    }

}

RE: void is an invalid type for the variable main

Small typo, I now see sad:

CODE

public static void main(String[] args) {

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close