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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 56204
    
  13

You expect your users to run your program in eclipse?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
John Jai
Bartender

Joined: May 31, 2011
Posts: 1778
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: 1778
Ok then read user input on cmd prompt using reader
Greg Brannon
Bartender

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


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 696

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 certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32701
    
    4
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to let user dynamically input parameter
 
Similar Threads
How to set JAVA_HOME Dynamically?
Input question
Running a java Application through web application
Creation of Java
repeat the function throws exception