• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run a Java Function from the Command line argument  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sir/Mam,

I have got two functions in my Java program,1)encrypt 2)decrypt, i want some command to execute that function from the command line, like when i call encrypt function it should execute that function and when i call degrypt it should execute that function, any help will be highly appreciated.
Thank you
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a program with two methods (not functions) called encrypt and decrypt.

You'll have to write a regular Java program with a main() method, and call your encrypt or decrypt method in the main() method.
 
aditya mrigank
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you sir, i am really sorry for the word Function, yes exactly its method, thanks a lot for the solution.
 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to follow Jesper's suggestion, the Scanner class is your friend when you want to parse the args[] in your main method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!