• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java static Method  RSS feed

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How to call the static method directly from the command prompt.

I have a class it contains some static methods and main methods. How to the static method directly from the command prompt.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you write your own JVM, you can't.

You might be able to pass the name of the method as a command-line argument and use reflection to invoke it; that is as near as I can think to what you are suggesting.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Unless you write your own JVM, you can't.


No. It's much simpler than that. You only have to write your own JVM launcher !
If you feel up to the challenge, the Invocation API is where you need to start, but this is definitely not a subject for beginners.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice to see you again, Joanne

I shall follow your hint and move this thread.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!