• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java application

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am new to java and I am trying to learn java using the head first java II Edition. I am using Eclispse. For certain practise programs when I want to run it as a java application, that option is not coming. Only option that comes is run in server. Please help me understand why is it so. The program which I am not able to run as java application is posted below.

[ October 26, 2008: Message edited by: david john ]
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Campbell Ritchie said in your other thread, please check your private messages.

And also please Use Code Tags.
 
david john
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Done sir... i will take care of the [code tags] from the next posts... thanks for helping.... please help me understand the issue posted
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the edit button to modify your post yourself.

The problem is, your main method is not static. It should really be public static void; if either public or static is missing the JVM cannot find it.

That will give you some more (compiler) problems, but those can be solved by checking your class setup. Making all your inner classes static will already help a lot.
 
david john
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob... got the point!
 
david john
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was able to run the program after making the main method and the class containing the main method as static. Now I am able to run the program as java application. I again checked in the Head First Second Edition book. there they have only mentioned the method as static and not the class as static. Is it a print error or something else.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have that book, but did they have the classes inside that "game" class? I doubt it.
 
david john
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it was not under game class, in the book 3 sepearate class are mentioned. I clubbed them under one class. In the book it was not under one class. I did not understand how will it make difference. Sorry for such silly questions but i am still in learning stage.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You ought to have lots of classes; each class should represent one sort of thing. Don't try squashing them all into a single class.
 
david john
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.... Guess I m still not getting the concept of static.... I will try to learn that first... :roll:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic