This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to let user dynamically input parameter

 
cake naiyou
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".
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
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?
 
John Jai
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
 
Greg Brannon
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.
 
Abhay Agarwal
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
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic