aspose file tools*
The moose likes Beginning Java and the fly likes How to let user dynamically input parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to let user dynamically input parameter" Watch "How to let user dynamically input parameter" New topic
Author

How to let user dynamically input parameter

cake naiyou
Greenhorn

Joined: Apr 29, 2011
Posts: 27
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

Joined: Jan 10, 2002
Posts: 61609
    
  67

You expect your users to run your program in eclipse?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Use Reader to read console input use or code Swing. Is this for an Eclipse enhancement requirement
cake naiyou
Greenhorn

Joined: Apr 29, 2011
Posts: 27
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
Bartender

Joined: May 31, 2011
Posts: 1776
Ok then read user input on cmd prompt using reader
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Alternately, allow the user to specify the input information in a command line parameter.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1212
    
    1

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


Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
You can use a command-line argument, or the Scanner class is much easier to use than a Reader for keyboard input.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to let user dynamically input parameter