?
Solved

passing variables as arguments in java

Posted on 2006-05-07
4
Medium Priority
?
271 Views
Last Modified: 2010-03-31
hi.. a number, 500, is being passed as an argument as shown:

p = r.exec(new String[] {"cmd.exe", "/k", "start", "c:\\a\\test.exe", "500"}, null, new File("c:/a"));

can this number be defined as int number and be passed as an argument....  thanks
0
Comment
Question by:bde521
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 16627175
no, not really. command arguments are always strings.

If you want to use a int var then you could do this:

int n = 500;
p = r.exec(new String[] {"cmd.exe", "/k", "start", "c:\\a\\test.exe", Integer.toString(n)}, null, new File("c:/a"));
0
 

Author Comment

by:bde521
ID: 16627210
objects.... it works...
one question i may need to pass more than one.... could i just add it to Integer.toString as:
int n = 500;
int x = 120;
p = r.exec(new String[] {"cmd.exe", "/k", "start", "c:\\a\\test.exe", Integer.toString(n, x)}, null, new File("c:/a"));
thanks ....
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 16627218
depends how it is expecting the vars, if its expecting two numbers then try:

p = r.exec(new String[] {"cmd.exe", "/k", "start", "c:\\a\\test.exe", Integer.toString(n), Integer.toString(x)}, null, new File("c:/a"));
0
 

Author Comment

by:bde521
ID: 16627236
objects.. thanks.. bde
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question