Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java application

 
david john
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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 ]
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Rob... got the point!
 
david john
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50258
79
  • Mark post as helpful
  • send pies
  • 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
  • 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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic