Click here to Skip to main content
14,981,532 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created this very simple code to start learning how to program. When I went onto my terminal I first went into the correct directry, and then typed javac the class and java class are both present in the folder. I tried to run it after that by typing, java Calc. But I got this error (
Exception in thread "main" java.lang.NoSuchMethodError: main) What could I be doing wrong here?

public class Calc {

    public void brown ()
        int a = 0;
        int b = 0;

The message is simple: you can not start an application that has no entry point. See the most used demo:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");

Do you see the difference? This will run, since it has a public static void main(String[] args) signed method. Do like this. Of course, you can have other methods too.
My 5. We answered almost at the same time. :-)
Zoltán Zörgő 1-Apr-13 16:41pm
Yes :)
helloworld..s 1-Apr-13 16:41pm
This type of application needs an entry point method, "main". As I can understand from your exception message, it is missing. Please, for example, use these directions:[^].

To get some background on the topic, please see:[^].

helloworld..s 1-Apr-13 16:41pm
Thank you!
You are welcome.
Good luck, call again.
Zoltán Zörgő 1-Apr-13 16:41pm
Of course, it is also a 5!
Thank you, Zoltán.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900