This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Displaying name of class that contains main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Displaying name of class that contains main" Watch "Displaying name of class that contains main" New topic
Author

Displaying name of class that contains main

Pete Hitchman
Greenhorn

Joined: Oct 29, 2002
Posts: 4
Hi,
I am writing a java application and I am checking the number of arguments passed on the
command line and if this fails printing out a
usage message. I would like the usage message
to include the name of the class that contains
the main method. How do I access this information?


Regards<br /> <br />Pete
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Try this

Rene


Regards, Rene Larsen
Dropbox Invite
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If you are WRITING the app . . .

(I must be missing something here . . . )


"JavaRanch, where the deer and the Certified play" - David O'Meara
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

or if you want to get the Class name from a method other then a static one:

Rene
Pete Hitchman
Greenhorn

Joined: Oct 29, 2002
Posts: 4
Thanks people.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying name of class that contains main
 
Similar Threads
why is this happening REALLY URGENT
Finding the caller of a class
Java 5.0 static import same members collision from different classes
help with MemoryPoolMXBeans
Error in Eclipse and Netbeans