This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What would be the command line argument be?  RSS feed

 
Simon Joseph Aquilina
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created the following example in D.java



I always assumed that to run a java program both class and main method must be public. However eclipse allows me to start either D1 or D2.

What would be the command line argument to start a program from the main method in for example class D1 which is defined in the file D.java?


 
Stephan van Hulst
Saloon Keeper
Posts: 6979
110
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java D1
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you'll find is that although these are both in the source file D.java, the compiled files will be D1.class and D2.class.
 
Simon Joseph Aquilina
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:What you'll find is that although these are both in the source file D.java, the compiled files will be D1.class and D2.class.


You are right, you are right!!! ... I should be ashamed of myself!!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!