-11

When I used the BlueJ IDE, I was able to run programs without using a main() method, whereas when I try the same code in NetBeans it says that the program doesn't have a main() method.

Boann
  • 44,932
  • 13
  • 106
  • 138
  • 2
    You're going to have to give a lot more information to get help. – Robert Moskal Jun 25 '15 at 14:31
  • 1
    Try posting your code for starters. – Rey Libutan Jun 25 '15 at 14:31
  • can you post your code and error what you are getting. I think you are not written public static void main(String args[]) method this is the main method which is executed first means execution starts from here only.. – Hanuman Jun 25 '15 at 14:31
  • 2
    That's because java programs have to have a main method. It's likely that BlueJ allows you to run snippets of code instead of forcing you to write an entire program. – azurefrog Jun 25 '15 at 14:32
  • `BlueJ` probably wraps your code in a `main` method...In `Java` you need a `main` method to run code... – brso05 Jun 25 '15 at 14:39
  • “I am new to java and programming“ is not a good headline. Try something more declarative, e.g. something with main, BlueJ and Eclipse. – Alexander Jun 25 '15 at 14:41

1 Answers1

2

BlueJ is a development environment which is a deliberately smaller and simpler interface than professional environments like NetBeans or Eclipse. This allows beginners to get started more quickly and hence doesnt force you to write the main() instead it does it for you in the background

https://www.cs.utexas.edu/users/scottm/cs307/handouts/BlueJProjectInstructions.html

Where as Netbeans and Eclipse mandate that you type code manually rather than use a drag and drop approach which is there in BlueJ.

Having said that public static void main(String[] arg){...} is the starting point for a standard standalone program.

Mudassar
  • 2,669
  • 13
  • 21