Click here to Skip to main content
11,496,146 members (347 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: Java
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;
Posted 1-Apr-13 11:34am
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.
Sergey Alexandrovich Kryukov at 1-Apr-13 16:40pm
My 5. We answered almost at the same time. :-)
Zoltán Zörgő at 1-Apr-13 16:41pm
Yes :)
helloworld..s at 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 at 1-Apr-13 16:41pm
Thank you!
Sergey Alexandrovich Kryukov at 1-Apr-13 16:42pm
You are welcome.
Good luck, call again.
Zoltán Zörgő at 1-Apr-13 16:41pm
Of course, it is also a 5!
Sergey Alexandrovich Kryukov at 1-Apr-13 16:43pm
Thank you, Zoltán.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 1 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100