Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Java, Java 7 Edition
This is the forum to discuss the Wrox book Ivor Horton's Beginning Java, Java 7 Edition by Ivor Horton ; ISBN: 978-0-470-40414-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Java, Java 7 Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2012, 02:05 PM
Registered User
 
Join Date: Mar 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Eclipse runs it Netbeans & notepad don't

Hi

On page 10, Chapter 1 the very first Java code MyFirstApplet it will run on Eclipse but not with Netbeans or Notepad ,the reason cited is the program doesn't have a main method and recommends changing the method from public void paint to public static void main (String args [])

Why does it run on Eclipse then and not the others
 
Old May 6th, 2012, 05:31 AM
Registered User
 
Join Date: May 2012
Posts: 9
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by Vincent View Post
Hi

On page 10, Chapter 1 the very first Java code MyFirstApplet it will run on Eclipse but not with Netbeans or Notepad ,the reason cited is the program doesn't have a main method and recommends changing the method from public void paint to public static void main (String args [])

Why does it run on Eclipse then and not the others
The reason why the notepad version of your program generates error is because you didnt define main() as static.
What static does is it tells javac and java that hey, even though the class does not have any objects you are still supposed to compile/execute this method.
And it makes sense to have main() as a static method because all your objects that are created are created within the main() method. So you must be able to execute main() even though there are no objects.

and just imprint it in your head main() will always be
Code:
 public static void main(String[] args)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 1 - using netbeans Wessam Khalil BOOK: Beginning Android Application Development 2 October 30th, 2011 06:03 PM
NetBeans? Eclipse? Notepad? elAmericano BOOK: Beginning Java 2, JDK 5 Edition 5 October 25th, 2010 11:52 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
J2EE + NetBeans 3.6 allruiz J2EE 1 August 9th, 2004 12:15 AM
NetBeans and WebServices/ANT sakalou J2EE 0 February 3rd, 2004 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.