In my current program, the input information is hard coded. For instance

final String titleFieldName = "title1";

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".

Recommended Answers

All 5 Replies

are we talking about a GUI, web based, command prompt application?
for the latter, use scanner (or an alternative, duh) to input values, and store them into your variable.

for the first two, there are methods that help you doing this, but you'll have to be a bit more specific.
also, can you show us a bit what you've got so far of code?

Will the user be using Eclipse to execute your program?
Or do you plan on creating a jar file that can be copied to other locations?

How can I change the program to allow the user dynamically input the parameter after clcking "run Java application".

How does Eclipse get involved here? What if the program is not in Eclipse?
For a normal program with a GUI interface, the user can enter a String via a text field and then that String can be copied to a local, non-final variable.

It should be command prompt application. Thanks.

are we talking about a GUI, web based, command prompt application?
for the latter, use scanner (or an alternative, duh) to input values, and store them into your variable.

for the first two, there are methods that help you doing this, but you'll have to be a bit more specific.
also, can you show us a bit what you've got so far of code?

Will the user be using Eclipse to execute your program?
Or do you plan on creating a jar file that can be copied to other locations?

then I would advise you to take a close look at the Scanner class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.