• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to let user dynamically input parameter  RSS feed

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my current program, the input information is hard coded. For instance


If I want to change title1 to title2, I have to modify the source code and click "run Java application" in Eclipse. How can I change the program to allow the user dynamically input the parameter after clcking "run Java application".
 
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You expect your users to run your program in eclipse?
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Reader to read console input use or code Swing. Is this for an Eclipse enhancement requirement
 
cake naiyou
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application should be command prompt one. At present, the debugging and testing process will be done in Eclipse.
Bear Bibeault wrote:You expect your users to run your program in eclipse?
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok then read user input on cmd prompt using reader
 
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternately, allow the user to specify the input information in a command line parameter.
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it is a stand alone program (which uses public static void main(String[] args)) then you can use pass arguments at runtime.



If you compile and run this class as
java Testing qwerty

then 'qwerty' will printed by
line

~ abhay
 
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a command-line argument, or the Scanner class is much easier to use than a Reader for keyboard input.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!