public class Student {
    private String name;

    public Student(String nameIn) {
        name = nameIn;
    }

    public String getName() {
        return name;
    }

    public void setName(String nameIn) {
        name = nameIn;
    }
}

and i get this error
Exception in thread "main" java.lang.NoSuchMethodError: main

Recommended Answers

All 3 Replies

That is because when you ask JRE to run your program, it loads the class and tries to call main().
Understandably it doesn't find one and gives the error.
Solution: Define main()

sry but i was a fool as this is a class and class never runs lol

this is a class and class never runs lol

Not exactly true, in Java the main() function is a member of the class you're trying to run. So in effect you are running a class. :)

Anyway I think you got the issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.